diff --git a/Signal/src/AppDelegate.m b/Signal/src/AppDelegate.m index 31433bb35..c9c45a53b 100644 --- a/Signal/src/AppDelegate.m +++ b/Signal/src/AppDelegate.m @@ -69,6 +69,7 @@ static NSTimeInterval launchStartedAt; @property (nonatomic) BOOL hasInitialRootViewController; @property (nonatomic) BOOL areVersionMigrationsComplete; @property (nonatomic) BOOL didAppLaunchFail; +@property (nonatomic) BOOL hasReceivedLocalNotification; @end @@ -525,6 +526,9 @@ static NSTimeInterval launchStartedAt; [self handleActivation]; }]; + // We want to process up to one local notification per activation, so clear the flag. + self.hasReceivedLocalNotification = NO; + DDLogInfo(@"%@ applicationDidBecomeActive completed.", self.logTag); } @@ -876,6 +880,13 @@ static NSTimeInterval launchStartedAt; return; } + // Don't process more than one local notification per activation. + if (self.hasReceivedLocalNotification) { + OWSFail(@"%@ %s ignoring redundant local notification.", self.logTag, __PRETTY_FUNCTION__); + return; + } + self.hasReceivedLocalNotification = YES; + DDLogInfo(@"%@ %s %@", self.logTag, __PRETTY_FUNCTION__, notification); [AppStoreRating preventPromptAtNextTest]; @@ -923,6 +934,13 @@ static NSTimeInterval launchStartedAt; return; } + // Don't process more than one local notification per activation. + if (self.hasReceivedLocalNotification) { + OWSFail(@"%@ %s ignoring redundant local notification.", self.logTag, __PRETTY_FUNCTION__); + return; + } + self.hasReceivedLocalNotification = YES; + // The docs for handleActionWithIdentifier:... state: // "You must call [completionHandler] at the end of your method.". // Nonetheless, it is presumably safe to call the completion handler