Launch app in background automatically?

六眼飞鱼酱① 提交于 2019-12-01 12:51:51

问题


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


来源:https://stackoverflow.com/questions/30867117/launch-app-in-background-automatically

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!