Handle background fetch errors

pull/33/head
Niels Andriesse 6 years ago
parent 96b077b1b4
commit 71d48e4be4

@ -1179,22 +1179,14 @@ static NSTimeInterval launchStartedAt;
- (void)application:(UIApplication *)application - (void)application:(UIApplication *)application
performFetchWithCompletionHandler:(void (^)(UIBackgroundFetchResult result))completionHandler performFetchWithCompletionHandler:(void (^)(UIBackgroundFetchResult result))completionHandler
{ {
OWSLogInfo(@"performing background fetch"); NSLog(@"[Loki] Performing background fetch.");
[AppReadiness runNowOrWhenAppDidBecomeReady:^{ [AppReadiness runNowOrWhenAppDidBecomeReady:^{
// Loki: We don't want to spin up the long poller here as it is probably wasteful on resources
__block AnyPromise *job = [AppEnvironment.shared.messageFetcherJob run].then(^{ __block AnyPromise *job = [AppEnvironment.shared.messageFetcherJob run].then(^{
// HACK: Call completion handler after n seconds. completionHandler(UIBackgroundFetchResultNewData);
// job = nil;
// We don't currently have a convenient API to know when message fetching is *done* when }).catch(^{
// working with the websocket. completionHandler(UIBackgroundFetchResultFailed);
// job = nil;
// We *could* substantially rewrite the TSSocketManager to take advantage of the `empty` message
// But once our REST endpoint is fixed to properly de-enqueue fallback notifications, we can easily
// use the rest endpoint here rather than the websocket and circumvent making changes to critical code.
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
completionHandler(UIBackgroundFetchResultNewData);
job = nil;
});
}); });
[job retainUntilComplete]; [job retainUntilComplete];
}]; }];

Loading…
Cancel
Save