diff --git a/Signal/Signal-Info.plist b/Signal/Signal-Info.plist index c49053bcc..378a5f3ca 100644 --- a/Signal/Signal-Info.plist +++ b/Signal/Signal-Info.plist @@ -7,7 +7,7 @@ CarthageVersion 0.33.0 OSXVersion - 10.15.2 + 10.15.3 WebRTCCommit 1445d719bf05280270e9f77576f80f973fd847f8 M73 diff --git a/Signal/src/AppDelegate.m b/Signal/src/AppDelegate.m index 9d7e3e293..61f8f0c5c 100644 --- a/Signal/src/AppDelegate.m +++ b/Signal/src/AppDelegate.m @@ -1133,7 +1133,7 @@ static NSTimeInterval launchStartedAt; return; } - CurrentAppContext().isWakenByRemoteNotification = true; + CurrentAppContext().wasWokenUpBySilentPushNotification = true; [LKLogger print:@"[Loki] Silent push notification received; fetching messages."]; @@ -1162,11 +1162,11 @@ static NSTimeInterval launchStartedAt; PMKJoin(promises).then(^(id results) { completionHandler(UIBackgroundFetchResultNewData); - CurrentAppContext().isWakenByRemoteNotification = false; + CurrentAppContext().wasWokenUpBySilentPushNotification = false; [LKLogger print:@"[Loki] UIBackgroundFetchResultNewData"]; }).catch(^(id error) { completionHandler(UIBackgroundFetchResultFailed); - CurrentAppContext().isWakenByRemoteNotification = false; + CurrentAppContext().wasWokenUpBySilentPushNotification = false; [LKLogger print:@"[Loki] UIBackgroundFetchResultFailed"]; }); } @@ -1599,13 +1599,15 @@ static NSTimeInterval launchStartedAt; { [self setUpLongPollerIfNeeded]; [self.lokiLongPoller startIfNeeded]; + // FIXME: Let's not mix long polling and public chat polling. Better to separate them out into their own functions. [LKPublicChatManager.shared startPollersIfNeeded]; - [SSKEnvironment.shared.attachmentDownloads startDownloadIfNeeded]; + [SSKEnvironment.shared.attachmentDownloads continueDownloadIfPossible]; } - (void)stopLongPollerIfNeeded { [self.lokiLongPoller stopIfNeeded]; + // FIXME: Let's not mix long polling and public chat polling. Better to separate them out into their own functions. [LKPublicChatManager.shared stopPollers]; } diff --git a/Signal/src/Loki/Utilities/LokiPushNotificationManager.swift b/Signal/src/Loki/Utilities/LokiPushNotificationManager.swift index 411f9a229..9624c4323 100644 --- a/Signal/src/Loki/Utilities/LokiPushNotificationManager.swift +++ b/Signal/src/Loki/Utilities/LokiPushNotificationManager.swift @@ -22,8 +22,11 @@ final class LokiPushNotificationManager : NSObject { } // Send token to Loki server let parameters = [ "token" : hexEncodedToken ] + #if DEBUG + let url = URL(string: "https://dev.apns.getsession.org/register")! + #else let url = URL(string: "https://live.apns.getsession.org/register")! -// let url = URL(string: "https://dev.apns.getsession.org/register")! + #endif let request = TSRequest(url: url, method: "POST", parameters: parameters) request.allHTTPHeaderFields = [ "Content-Type" : "application/json" ] TSNetworkManager.shared().makeRequest(request, success: { _, response in diff --git a/Signal/src/util/MainAppContext.m b/Signal/src/util/MainAppContext.m index 30bf7524e..7a7139312 100644 --- a/Signal/src/util/MainAppContext.m +++ b/Signal/src/util/MainAppContext.m @@ -28,7 +28,7 @@ NSString *const ReportedApplicationStateDidChangeNotification = @"ReportedApplic @synthesize mainWindow = _mainWindow; @synthesize appLaunchTime = _appLaunchTime; -@synthesize isWakenByRemoteNotification = _isWakenByRemoteNotification; +@synthesize wasWokenUpBySilentPushNotification = _wasWokenUpBySilentPushNotification; - (instancetype)init { @@ -41,7 +41,7 @@ NSString *const ReportedApplicationStateDidChangeNotification = @"ReportedApplic self.reportedApplicationState = UIApplicationStateInactive; _appLaunchTime = [NSDate new]; - _isWakenByRemoteNotification = false; + _wasWokenUpBySilentPushNotification = false; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationWillEnterForeground:) diff --git a/SignalServiceKit/src/Messages/Attachments/OWSAttachmentDownloads.h b/SignalServiceKit/src/Messages/Attachments/OWSAttachmentDownloads.h index c36382ca6..74b9553f8 100644 --- a/SignalServiceKit/src/Messages/Attachments/OWSAttachmentDownloads.h +++ b/SignalServiceKit/src/Messages/Attachments/OWSAttachmentDownloads.h @@ -43,7 +43,7 @@ extern NSString *const kAttachmentDownloadAttachmentIDKey; success:(void (^)(NSArray *attachmentStreams))success failure:(void (^)(NSError *error))failure; -- (void)startDownloadIfNeeded; +- (void)continueDownloadIfPossible; @end diff --git a/SignalServiceKit/src/Messages/Attachments/OWSAttachmentDownloads.m b/SignalServiceKit/src/Messages/Attachments/OWSAttachmentDownloads.m index f853fd484..f98e71815 100644 --- a/SignalServiceKit/src/Messages/Attachments/OWSAttachmentDownloads.m +++ b/SignalServiceKit/src/Messages/Attachments/OWSAttachmentDownloads.m @@ -264,7 +264,7 @@ typedef void (^AttachmentDownloadFailure)(NSError *error); - (void)startDownloadIfPossible { - if (CurrentAppContext().isWakenByRemoteNotification) { return; } + if (CurrentAppContext().wasWokenUpBySilentPushNotification) { return; } dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ OWSAttachmentDownloadJob *_Nullable job; @@ -344,10 +344,10 @@ typedef void (^AttachmentDownloadFailure)(NSError *error); #pragma mark - -- (void)startDownloadIfNeeded +- (void)continueDownloadIfPossible { if (self.attachmentDownloadJobQueue.count > 0) { - [LKLogger print:@"[Loki] start uncompleted attachment download tasks"]; + [LKLogger print:@"[Loki] Continuing unfinished attachment download tasks."]; [self startDownloadIfPossible]; } } diff --git a/SignalServiceKit/src/Util/AppContext.h b/SignalServiceKit/src/Util/AppContext.h index 5ca48b4d3..9a0fd9d4d 100755 --- a/SignalServiceKit/src/Util/AppContext.h +++ b/SignalServiceKit/src/Util/AppContext.h @@ -37,8 +37,9 @@ NSString *NSStringForUIApplicationState(UIApplicationState value); @property (nonatomic, readonly) BOOL isMainApp; @property (nonatomic, readonly) BOOL isMainAppAndActive; -//A flag to determine if the attatchment downloading tasks should run -@property (nonatomic) BOOL isWakenByRemoteNotification; +/// Whether the app was woken up by a silent push notification. This is important for +/// determining whether attachments should be downloaded or not. +@property (nonatomic) BOOL wasWokenUpBySilentPushNotification; // Whether the user is using a right-to-left language like Arabic. @property (nonatomic, readonly) BOOL isRTL;