Merge tag '2.27.1.4'

pull/1/head
Michael Kirk 7 years ago
commit c40c2a632b

@ -69,7 +69,6 @@ static NSTimeInterval launchStartedAt;
@property (nonatomic) BOOL hasInitialRootViewController; @property (nonatomic) BOOL hasInitialRootViewController;
@property (nonatomic) BOOL areVersionMigrationsComplete; @property (nonatomic) BOOL areVersionMigrationsComplete;
@property (nonatomic) BOOL didAppLaunchFail; @property (nonatomic) BOOL didAppLaunchFail;
@property (nonatomic) BOOL hasReceivedLocalNotification;
@end @end
@ -539,8 +538,10 @@ static NSTimeInterval launchStartedAt;
[self handleActivation]; [self handleActivation];
}]; }];
// We want to process up to one local notification per activation, so clear the flag. // There is a sequence of actions a user can take where we present a conversation from a notification
self.hasReceivedLocalNotification = NO; // multiple times, producing an undesirable "stack" of multiple conversation view controllers.
// So we ensure that we only present conversations once per activate.
[PushManager sharedManager].hasPresentedConversationSinceLastDeactivation = NO;
// Clear all notifications whenever we become active. // Clear all notifications whenever we become active.
// When opening the app from a notification, // When opening the app from a notification,
@ -909,13 +910,6 @@ static NSTimeInterval launchStartedAt;
return; 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); DDLogInfo(@"%@ %s %@", self.logTag, __PRETTY_FUNCTION__, notification);
[AppStoreRating preventPromptAtNextTest]; [AppStoreRating preventPromptAtNextTest];
@ -956,6 +950,8 @@ static NSTimeInterval launchStartedAt;
withResponseInfo:(NSDictionary *)responseInfo withResponseInfo:(NSDictionary *)responseInfo
completionHandler:(void (^)())completionHandler completionHandler:(void (^)())completionHandler
{ {
DDLogInfo(@"%@ handling action with identifier: %@", self.logTag, identifier);
OWSAssertIsOnMainThread(); OWSAssertIsOnMainThread();
if (self.didAppLaunchFail) { if (self.didAppLaunchFail) {
@ -963,13 +959,6 @@ static NSTimeInterval launchStartedAt;
return; 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: // The docs for handleActionWithIdentifier:... state:
// "You must call [completionHandler] at the end of your method.". // "You must call [completionHandler] at the end of your method.".
// Nonetheless, it is presumably safe to call the completion handler // Nonetheless, it is presumably safe to call the completion handler

@ -1,5 +1,5 @@
// //
// Copyright (c) 2017 Open Whisper Systems. All rights reserved. // Copyright (c) 2018 Open Whisper Systems. All rights reserved.
// //
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
@ -37,6 +37,8 @@ typedef void (^pushTokensSuccessBlock)(NSString *pushToken, NSString *voipToken)
*/ */
@interface PushManager : NSObject @interface PushManager : NSObject
@property (nonatomic) BOOL hasPresentedConversationSinceLastDeactivation;
- (instancetype)init NS_UNAVAILABLE; - (instancetype)init NS_UNAVAILABLE;
+ (PushManager *)sharedManager; + (PushManager *)sharedManager;

@ -134,7 +134,7 @@ NSString *const Signal_Message_MarkAsRead_Identifier = @"Signal_Message_MarkAsRe
DDLogInfo(@"%@ received content-available push", self.logTag); DDLogInfo(@"%@ received content-available push", self.logTag);
// If we want to re-introduce silent pushes we can remove this assert. // If we want to re-introduce silent pushes we can remove this assert.
OWSFail(@"Unexpected content-available push."); OWSProdLogAndFail(@"Unexpected content-available push.");
[AppReadiness runNowOrWhenAppIsReady:^{ [AppReadiness runNowOrWhenAppIsReady:^{
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 20 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 20 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
@ -143,6 +143,20 @@ NSString *const Signal_Message_MarkAsRead_Identifier = @"Signal_Message_MarkAsRe
}]; }];
} }
- (void)presentOncePerActivationConversationWithThreadId:(NSString *)threadId
{
if (self.hasPresentedConversationSinceLastDeactivation) {
OWSProdLogAndFail(@"%@ in %s refusing to present conversation: %@ multiple times.",
self.logTag,
__PRETTY_FUNCTION__,
threadId);
return;
}
self.hasPresentedConversationSinceLastDeactivation = YES;
[SignalApp.sharedApp presentConversationForThreadId:threadId];
}
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification - (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
{ {
OWSAssertIsOnMainThread(); OWSAssertIsOnMainThread();
@ -151,9 +165,9 @@ NSString *const Signal_Message_MarkAsRead_Identifier = @"Signal_Message_MarkAsRe
NSString *_Nullable threadId = notification.userInfo[Signal_Thread_UserInfo_Key]; NSString *_Nullable threadId = notification.userInfo[Signal_Thread_UserInfo_Key];
if (threadId) { if (threadId) {
[SignalApp.sharedApp presentConversationForThreadId:threadId]; [self presentOncePerActivationConversationWithThreadId:threadId];
} else { } else {
OWSFail(@"%@ threadId was unexpectedly nil in %s", self.logTag, __PRETTY_FUNCTION__); OWSProdLogAndFail(@"%@ threadId was unexpectedly nil in %s", self.logTag, __PRETTY_FUNCTION__);
} }
// We only want to receive a single local notification per launch. // We only want to receive a single local notification per launch.
@ -259,18 +273,20 @@ NSString *const Signal_Message_MarkAsRead_Identifier = @"Signal_Message_MarkAsRe
NSString *threadId = notification.userInfo[Signal_Thread_UserInfo_Key]; NSString *threadId = notification.userInfo[Signal_Thread_UserInfo_Key];
if (threadId) { if (threadId) {
[SignalApp.sharedApp presentConversationForThreadId:threadId]; [self presentOncePerActivationConversationWithThreadId:threadId];
} else { } else {
OWSFail(@"%@ threadId was unexpectedly nil in action with identifier: %@", self.logTag, identifier); OWSProdLogAndFail(
@"%@ threadId was unexpectedly nil in action with identifier: %@", self.logTag, identifier);
} }
completionHandler(); completionHandler();
} else { } else {
OWSFail(@"%@ Unhandled action with identifier: %@", self.logTag, identifier); OWSProdLogAndFail(@"%@ Unhandled action with identifier: %@", self.logTag, identifier);
NSString *threadId = notification.userInfo[Signal_Thread_UserInfo_Key]; NSString *threadId = notification.userInfo[Signal_Thread_UserInfo_Key];
if (threadId) { if (threadId) {
[SignalApp.sharedApp presentConversationForThreadId:threadId]; [self presentOncePerActivationConversationWithThreadId:threadId];
} else { } else {
OWSFail(@"%@ threadId was unexpectedly nil in action with identifier: %@", self.logTag, identifier); OWSProdLogAndFail(
@"%@ threadId was unexpectedly nil in action with identifier: %@", self.logTag, identifier);
} }
completionHandler(); completionHandler();
} }

Loading…
Cancel
Save