自动在后台启动应用程序? [英] Launch app in background automatically?

查看:36
本文介绍了自动在后台启动应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法将 iOS 应用程序保留在后台,使其在设备开启时自动启动,并在终止后重新启动?我已经阅读了一些关于 voip 和 gps 服务的帖子.我的应用程序发送带有用户位置的紧急短信.它需要保持活跃以侦听遇险触发.是否可以通过使用 APNS 服务器向应用发送推送通知来自动启动应用?

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?

推荐答案

是的,您可以使用 APNS 启动您的应用.

Yes, you can start your app using APNS.

1) 您必须在通知正文中将content-available"设置为 1.

1) You have to set "content-available" to 1 in the notification body.

2) 你必须实施:

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler

3) 并有正确的背景模式:背景模式

3) And have the right background modes: Background Modes

但请注意,您的用户可以通过在 iPhone 设置中禁用后台应用刷新来关闭此功能.您可以在代码中检查:

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

这篇关于自动在后台启动应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆