Is there a way to persist an iOS app in the background such that it starts up automatically when the device is turned on and will re-launch later if terminated? I have read a few posts on either voip and gps services. My app sends emergency SMS messages with the user's location. It needs to remain active to listen for distress triggers. Would it be possibly to start up the app automatically with sending push notifications to the app using an APNS server?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Yes, you can start your app using APNS.
1) You have to set "content-available" to 1 in the notification body.
2) You have to implement:
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
3) And have the right background modes: Background Modes
But be careful, your users can turn this off by disabling Background App Refresh in the iPhone Settings. You can check this in code:
[UIApplication sharedApplication].backgroundRefreshStatus!=UIBackgroundRefreshStatusAvailable