diff --git a/Signal/src/UserInterface/Notifications/AppNotifications.swift b/Signal/src/UserInterface/Notifications/AppNotifications.swift index 4c2a4ba2f..1c1deadd8 100644 --- a/Signal/src/UserInterface/Notifications/AppNotifications.swift +++ b/Signal/src/UserInterface/Notifications/AppNotifications.swift @@ -496,10 +496,12 @@ public class NotificationPresenter: NSObject, NotificationsProtocol { } } + @objc public func cancelNotifications(threadId: String) { self.adaptee.cancelNotifications(threadId: threadId) } + @objc public func clearAllNotifications() { adaptee.clearAllNotifications() } diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m index 202bd46ec..a60661ae0 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m @@ -325,6 +325,11 @@ typedef enum : NSUInteger { return SSKEnvironment.shared.tsAccountManager; } +- (OWSNotificationPresenter *)notificationPresenter +{ + return AppEnvironment.shared.notificationPresenter; +} + #pragma mark - - (void)addNotificationListeners @@ -1187,6 +1192,13 @@ typedef enum : NSUInteger { { [super viewDidAppear:animated]; + // We don't present incoming message notifications for the presented + // conversation. But there's a narrow window *while* the conversationVC + // is being presented where a message notification for the not-quite-yet + // presented conversation can be shown. If that happens, dismiss it as soon + // as we enter the conversation. + [self.notificationPresenter cancelNotificationsWithThreadId:self.thread.uniqueId]; + // recover status bar when returning from PhotoPicker, which is dark (uses light status bar) [self setNeedsStatusBarAppearanceUpdate];