简体   繁体   English

有没有办法知道iOS是否以及为什么终止了您的应用程序?

[英]Is there a way to know if and why iOS terminated your app?

I'm trying to debug an issue with my iPhone app that seems to be getting terminated while running on the device (it never happens in the simulator). 我正在尝试调试我的iPhone应用程序的问题,该问题在设备上运行时似乎已终止(在模拟器中从未发生过)。 The app is for iOS 8 only. 该应用程序仅适用于iOS 8。

Once app enters the background (via the user hitting the home button) I start Significant-Change Location service. 一旦应用进入后台(通过用户点击主页按钮),我就会启动“重要更改位置”服务。 When a location updates happens while the app is suspended the system should put the app in the background where I then send an update to my server with the location. 当应用程序暂停时发生位置更新时,系统应将应用程序置于后台,然后我将包含该位置的更新发送到我的服务器。 That operation is wrapped in a proper beginBackgroundTaskWithExpirationHandler to allow me the time needed to make the network call. 该操作被包装在适当的beginBackgroundTaskWithExpirationHandler中,以允许我进行网络调用所需的时间。

It appears though my app is getting terminated by the system because sometimes when I resume the app from the suspended state it is no longer in the view last seen when minimizing but is back at the root controller as if starting from a fresh launch. 看来我的应用程序已被系统终止,因为有时当我从挂起状态恢复应用程序时,它不再处于最小化时最后一次看到的视图中,而是像重新启动一样回到根控制器。 It does not appear to be due to a crash as I do not see it in the crash log nor is New Relic reporting such. 它似乎不是由于崩溃引起的,因为我在崩溃日志中没有看到它,New Relic也没有报告这种情况。 The app is suspended though, not terminated, probably because it is getting launched again into the background from a location update. 该应用已暂停但未终止,可能是因为该应用从位置更新中再次被启动到后台。

The question is, is there a way to know that my app was indeed terminated by the system, and if so, for what reason(memory, exceeding background execution time, etc.) and at what time. 问题是,是否有办法知道我的应用确实已被系统终止,如果是,原因是什么(内存,超出后台执行时间等)以及在什么时间终止。 Is there a log kept somewhere containing this information? 是否在某处保存了包含此信息的日志?

I'm under the impression I can not use applicationWillTerminate because the docs say this is not called when an app is suspend. 我的印象是我不能使用applicationWillTerminate,因为文档说应用程序挂起时不会调用它。

在此处输入图片说明

You may check in Devices page. 您可以在“设备”页面中签入。 (Shortcut is Command + Shift + 2) (快捷键为Command + Shift + 2)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM