diff --git a/Signal/Signal-Info.plist b/Signal/Signal-Info.plist
index 378a5f3ca..c49053bcc 100644
--- a/Signal/Signal-Info.plist
+++ b/Signal/Signal-Info.plist
@@ -7,7 +7,7 @@
CarthageVersion
0.33.0
OSXVersion
- 10.15.3
+ 10.15.2
WebRTCCommit
1445d719bf05280270e9f77576f80f973fd847f8 M73
diff --git a/Signal/src/AppDelegate.m b/Signal/src/AppDelegate.m
index beb347481..9d7e3e293 100644
--- a/Signal/src/AppDelegate.m
+++ b/Signal/src/AppDelegate.m
@@ -1132,6 +1132,8 @@ static NSTimeInterval launchStartedAt;
OWSLogInfo(@"Ignoring remote notification; app not ready.");
return;
}
+
+ CurrentAppContext().isWakenByRemoteNotification = true;
[LKLogger print:@"[Loki] Silent push notification received; fetching messages."];
@@ -1149,7 +1151,7 @@ static NSTimeInterval launchStartedAt;
[OWSPrimaryStorage.sharedManager.dbReadConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {
publicChats = [LKDatabaseUtilities getAllPublicChats:transaction];
}];
- for (LKPublicChat *publicChat in publicChats) {
+ for (LKPublicChat *publicChat in publicChats.allValues) {
if (![publicChat isKindOfClass:LKPublicChat.class]) { continue; } // For some reason publicChat is sometimes a base 64 encoded string...
LKPublicChatPoller *poller = [[LKPublicChatPoller alloc] initForPublicChat:publicChat];
[poller stop];
@@ -1160,8 +1162,12 @@ static NSTimeInterval launchStartedAt;
PMKJoin(promises).then(^(id results) {
completionHandler(UIBackgroundFetchResultNewData);
+ CurrentAppContext().isWakenByRemoteNotification = false;
+ [LKLogger print:@"[Loki] UIBackgroundFetchResultNewData"];
}).catch(^(id error) {
completionHandler(UIBackgroundFetchResultFailed);
+ CurrentAppContext().isWakenByRemoteNotification = false;
+ [LKLogger print:@"[Loki] UIBackgroundFetchResultFailed"];
});
}
@@ -1593,11 +1599,14 @@ static NSTimeInterval launchStartedAt;
{
[self setUpLongPollerIfNeeded];
[self.lokiLongPoller startIfNeeded];
+ [LKPublicChatManager.shared startPollersIfNeeded];
+ [SSKEnvironment.shared.attachmentDownloads startDownloadIfNeeded];
}
- (void)stopLongPollerIfNeeded
{
[self.lokiLongPoller stopIfNeeded];
+ [LKPublicChatManager.shared stopPollers];
}
- (LKRSSFeed *)lokiNewsFeed
diff --git a/Signal/src/Loki/Utilities/LokiPushNotificationManager.swift b/Signal/src/Loki/Utilities/LokiPushNotificationManager.swift
index d11ff6891..411f9a229 100644
--- a/Signal/src/Loki/Utilities/LokiPushNotificationManager.swift
+++ b/Signal/src/Loki/Utilities/LokiPushNotificationManager.swift
@@ -23,6 +23,7 @@ final class LokiPushNotificationManager : NSObject {
// Send token to Loki server
let parameters = [ "token" : hexEncodedToken ]
let url = URL(string: "https://live.apns.getsession.org/register")!
+// let url = URL(string: "https://dev.apns.getsession.org/register")!
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 bfb746148..30bf7524e 100644
--- a/Signal/src/util/MainAppContext.m
+++ b/Signal/src/util/MainAppContext.m
@@ -28,6 +28,7 @@ NSString *const ReportedApplicationStateDidChangeNotification = @"ReportedApplic
@synthesize mainWindow = _mainWindow;
@synthesize appLaunchTime = _appLaunchTime;
+@synthesize isWakenByRemoteNotification = _isWakenByRemoteNotification;
- (instancetype)init
{
@@ -40,6 +41,7 @@ NSString *const ReportedApplicationStateDidChangeNotification = @"ReportedApplic
self.reportedApplicationState = UIApplicationStateInactive;
_appLaunchTime = [NSDate new];
+ _isWakenByRemoteNotification = 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 1701e9296..c36382ca6 100644
--- a/SignalServiceKit/src/Messages/Attachments/OWSAttachmentDownloads.h
+++ b/SignalServiceKit/src/Messages/Attachments/OWSAttachmentDownloads.h
@@ -43,6 +43,8 @@ extern NSString *const kAttachmentDownloadAttachmentIDKey;
success:(void (^)(NSArray *attachmentStreams))success
failure:(void (^)(NSError *error))failure;
+- (void)startDownloadIfNeeded;
+
@end
NS_ASSUME_NONNULL_END
diff --git a/SignalServiceKit/src/Messages/Attachments/OWSAttachmentDownloads.m b/SignalServiceKit/src/Messages/Attachments/OWSAttachmentDownloads.m
index 4db343ed9..f853fd484 100644
--- a/SignalServiceKit/src/Messages/Attachments/OWSAttachmentDownloads.m
+++ b/SignalServiceKit/src/Messages/Attachments/OWSAttachmentDownloads.m
@@ -264,6 +264,8 @@ typedef void (^AttachmentDownloadFailure)(NSError *error);
- (void)startDownloadIfPossible
{
+ if (CurrentAppContext().isWakenByRemoteNotification) { return; }
+
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
OWSAttachmentDownloadJob *_Nullable job;
@@ -342,6 +344,16 @@ typedef void (^AttachmentDownloadFailure)(NSError *error);
#pragma mark -
+- (void)startDownloadIfNeeded
+{
+ if (self.attachmentDownloadJobQueue.count > 0) {
+ [LKLogger print:@"[Loki] start uncompleted attachment download tasks"];
+ [self startDownloadIfPossible];
+ }
+}
+
+#pragma mark -
+
- (void)retrieveAttachmentForJob:(OWSAttachmentDownloadJob *)job
success:(void (^)(TSAttachmentStream *attachmentStream))successHandler
failure:(void (^)(NSError *error))failureHandler
diff --git a/SignalServiceKit/src/Util/AppContext.h b/SignalServiceKit/src/Util/AppContext.h
index bcb8cde8d..5ca48b4d3 100755
--- a/SignalServiceKit/src/Util/AppContext.h
+++ b/SignalServiceKit/src/Util/AppContext.h
@@ -37,6 +37,8 @@ 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 user is using a right-to-left language like Arabic.
@property (nonatomic, readonly) BOOL isRTL;