From ab57dccb96bc05d9471e197022ffc4c85ae40932 Mon Sep 17 00:00:00 2001 From: manuroe Date: Mon, 9 Oct 2017 11:29:53 +0200 Subject: [PATCH] A possible patch to avoid the app being killed in background on iOS11 (https://github.com/vector-im/riot-ios/issues/1522) --- Riot/AppDelegate.m | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Riot/AppDelegate.m b/Riot/AppDelegate.m index 1eebd2cb8..eedba7c26 100644 --- a/Riot/AppDelegate.m +++ b/Riot/AppDelegate.m @@ -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