Merge pull request #1561 from vector-im/kill_in_bg

A possible patch to avoid the app being killed in background on iOS11
This commit is contained in:
manuroe
2017-10-09 12:46:17 +02:00
committed by GitHub
+11 -3
View File
@@ -1053,9 +1053,17 @@ NSString *const kAppDelegateNetworkStatusDidChangeNotification = @"kAppDelegateN
}
}
NSLog(@"[AppDelegate] didReceiveRemoteNotification: BEFORE completionHandler");
completionHandler(UIBackgroundFetchResultNoData);
NSLog(@"[AppDelegate] didReceiveRemoteNotification: AFTER completionHandler");
// Possible workaround for https://github.com/vector-im/riot-ios/issues/1522
// iOS 11 ignores us when we say that we will not display a local notification
// making the app crash in background.
// So, try to send the information a bit later with a dispatch_async :/
NSLog(@"[AppDelegate] didReceiveRemoteNotification: BEFORE completionHandler #1");
dispatch_async(dispatch_get_main_queue(), ^{
NSLog(@"[AppDelegate] didReceiveRemoteNotification: BEFORE completionHandler #2");
completionHandler(UIBackgroundFetchResultNoData);
NSLog(@"[AppDelegate] didReceiveRemoteNotification: AFTER completionHandler");
});
}
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo