17

Skype 更新文本包含下一个:

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

如何通过 SDK 执行该操作?

4

5 回答 5

14

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

https://developer.apple.com/library/ios/#documentation/CoreLocation/Reference/CLLocationManager_Class/CLLocationManager/CLLocationManager.html#//apple_ref/doc/uid/TP40007125

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.

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

Update

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.

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.

http://developer.apple.com/library/ios/#documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/AdvancedAppTricks/AdvancedAppTricks.html#//apple_ref/doc/uid/TP40007072-CH7-SW12

于 2012-05-01T08:30:08.933 回答
3

Skype 正是这样做的:

  1. 为 VoIP 注册它的 TCP 套接字。
  2. 登录。
  3. 在非零退出代码时,iOS 将重新启动应用程序(因为 VoIP 应用程序需要保持运行才能接收来电,如果应用程序以非零退出代码退出,系统会自动重新启动应用程序。)。
  4. 然后它立即启动后台任务(重新启动的应用程序保持挂起)。
  5. 接下来,它为 VoIP 注册它的登录套接字。
  6. 它重新登录。
于 2012-05-16T03:33:11.083 回答
1

据我所知,它不可能重新启动您的应用程序..您可以使用杀死您的应用程序,exit(1); 但这是 Apple 不允许的,将被拒绝。也许您可以通过从 mainViewController 中删除一些视图并再次添加它并重置数据和内容来做一些解决方法.. 但是我不这么认为要真正重新启动。

于 2012-05-01T08:16:34.587 回答
1

不确定 Skype 有什么问题,但是 - 不幸的是,无法重新启动应用程序。甚至,没有办法退出/退出应用程序。(要退出,请参阅链接部分“不要以编程方式退出”)

于 2012-05-01T08:20:53.950 回答
0

问题是你为什么要这样做?,如果你的答案是:你想让一个应用程序在“iPad Kiosk”中运行,所以万一它崩溃了,你需要应用程序自动重启,那么,什么对你有用将 iPad 置于“ Kiosk 模式”,操作系统会在崩溃时自动重新启动应用程序。

看一眼:

http://www.webascender.com/Blog/ID/447/How-to-Setup-Kiosk-Mode-Lock-Your-iPad-to-Just-One-App

干杯,

于 2014-07-24T19:38:29.010 回答