Revision fa6e5004 ChatSecure/Classes/OTRAppDelegate.m
ChatSecure/Classes/OTRAppDelegate.m | ||
---|---|---|
83 | 83 |
|
84 | 84 |
@implementation OTRAppDelegate |
85 | 85 |
@synthesize window = _window; |
86 |
@dynamic activeThreadYapKey; |
|
87 | 86 |
|
88 | 87 |
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions |
89 | 88 |
{ |
... | ... | |
258 | 257 |
self.window.rootViewController = [self setupDefaultSplitViewControllerWithLeadingViewController:[[UINavigationController alloc] initWithRootViewController:self.conversationViewController]]; |
259 | 258 |
} |
260 | 259 |
|
261 |
- (NSString *)activeThreadYapKey |
|
262 |
{ |
|
263 |
NSString *threadOwnerYapKey = nil; |
|
264 |
if (self.messagesViewController && [self.messagesViewController otr_isVisible]) { |
|
265 |
threadOwnerYapKey = self.messagesViewController.threadKey; |
|
266 |
} |
|
267 |
return threadOwnerYapKey; |
|
268 |
} |
|
269 |
|
|
270 | 260 |
- (void)applicationWillResignActive:(UIApplication *)application |
271 | 261 |
{ |
272 | 262 |
[OTRProtocolManager sharedInstance].lastInteractionDate = [NSDate date]; |
... | ... | |
517 | 507 |
#pragma mark UNUserNotificationCenterDelegate methods (iOS 10+) |
518 | 508 |
|
519 | 509 |
- (void) userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler { |
520 |
if ([notification.request.content.threadIdentifier isEqualToString:[self activeThreadYapKey]]) { |
|
521 |
completionHandler(UNNotificationPresentationOptionNone); |
|
522 |
} else { |
|
523 |
completionHandler(UNNotificationPresentationOptionBadge | UNNotificationPresentationOptionSound | UNNotificationPresentationOptionAlert); |
|
524 |
} |
|
510 |
[OTRAppDelegate visibleThread:^(YapCollectionKey * _Nullable ck) { |
|
511 |
if ([ck.key isEqualToString:notification.request.content.threadIdentifier]) { |
|
512 |
completionHandler(UNNotificationPresentationOptionNone); |
|
513 |
} else { |
|
514 |
completionHandler(UNNotificationPresentationOptionBadge | UNNotificationPresentationOptionSound | UNNotificationPresentationOptionAlert); |
|
515 |
} |
|
516 |
} completionQueue:nil]; |
|
525 | 517 |
} |
526 | 518 |
|
527 | 519 |
- (void) userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)(void))completionHandler { |
Also available in: Unified diff