如果意外关机如何重新启动应用程序 [英] How to restart app if it unexpectedly shutdown

查看:188
本文介绍了如果意外关机如何重新启动应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Sk​​ype的更新文本包含下一:

应用程序自动重新启动,如果意外关闭

App auto restarts if unexpectedly shut down

如何可能通过SDK来执行?

How is possible to perform that via SDK?

推荐答案

据我所知,一些应用程序可以在后台运行,并且可以在特定的情况下重新启动。这是苹果公司的文档

As far as I know, some sort of apps can be run in background and can be restarted in specific case. This is from Apple docs

<一个href=\"https://developer.apple.com/library/ios/#documentation/CoreLocation/Reference/CLLocationManager_Class/CLLocationManager/CLLocationManager.html#//apple_ref/doc/uid/TP40007125\">https://developer.apple.com/library/ios/#documentation/CoreLocation/Reference/CLLocationManager_Class/CLLocationManager/CLLocationManager.html#//apple_ref/doc/uid/TP40007125

如果您启动该服务,并且您的应用程序随后终止时,系统会自动是否有新的事件到达将重新启动应用程序进入后台。在这种情况下,选择字典传递到应用程序中:didFinishLaunchingWithOptions:您的应用程序委托的方法中包含的关键UIApplicationLaunchOptionsLocationKey,表明您的应用程序,因为定位事件的发动

If you start this service and your application is subsequently terminated, the system automatically relaunches the application into the background if a new event arrives. In such a case, the options dictionary passed to the application:didFinishLaunchingWithOptions: method of your application delegate contains the key UIApplicationLaunchOptionsLocationKey to indicate that your application was launched because of a location event.

我的意见是:Skype正在重新启动与远程通知机制

My opinion is: Skype is relaunched with remote notifications mechanism.

更新

好吧,我想我发现了什么。 @Malek_Jundi是对了一半。您的应用程序应失败非零退出code,但它应该被注册为VoIP应用。

Well, I think I found something. @Malek_Jundi was half-right. Your app should fail with non-zero exit code, but it should be registered as VoIP application.

由于VoIP应用需要留在为了接收来电运行时,系统会自动,如果它以非零退出code退出将重新启动应用程序。 (这可能发生在情况下,有存储器pressure和应用程序被终止作为结果)。然而,终止该应用程序也释放其所有的插座,包括用于维护VoIP业务连接之一。因此,当应用程序启动,它总是需要从头开始建立它的插座。

Because VoIP applications need to stay running in order to receive incoming calls, the system automatically relaunches the application if it exits with a nonzero exit code. (This could happen in cases where there is memory pressure and your application is terminated as a result.) However, terminating the application also releases all of its sockets, including the one used to maintain the VoIP service connection. Therefore, when the application is launched, it always needs to create its sockets from scratch.

<一个href=\"http://developer.apple.com/library/ios/#documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/AdvancedAppTricks/AdvancedAppTricks.html#//apple_ref/doc/uid/TP40007072-CH7-SW12\">http://developer.apple.com/library/ios/#documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/AdvancedAppTricks/AdvancedAppTricks.html#//apple_ref/doc/uid/TP40007072-CH7-SW12

这篇关于如果意外关机如何重新启动应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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