简体   繁体   English

暂停应用程序后,如何在iPhone上获取屏幕锁定/解锁事件?

[英]How to get screen lock/unlock events on the iPhone when app is suspended?

I have a requirement where i need to track the iphone device state like if device is locked or unlocked. 我有一个需要跟踪iphone设备状态(例如设备是锁定还是未锁定)的要求。 I was able to track these events when the app is running in foreground or background. 当应用在前台或后台运行时,我能够跟踪这些事件。 But i also need to track the same when the app is suspended. 但是当应用程序暂停时,我还需要跟踪相同内容。 Something like tracking the user location in background when the app is suspended. 暂停应用后,例如在后台跟踪用户位置。 But i don't need to track the user location but only the device state. 但是我不需要跟踪用户位置,而只需跟踪设备状态。

Please suggest me some steps to solve this issue in objective-c.Thanks in advance. 请向我建议一些步骤来解决Objective-c中的问题。

You can not perform any operations once your app is in suspended state and you can not prevent your app from getting suspended unless you are using one of the background capability mode mentioned in this apple doc 一旦您的应用程序处于暂停状态,您将无法执行任何操作,也无法阻止您的应用程序被暂停,除非您使用的是本苹果文档中提到的一种后台功能模式

So what you are looking for is not possible if you are not using either of background modes allowed by apple. 因此,如果您没有使用apple允许的任何一种背景模式,那么您无法找到所需的内容。

EDIT 编辑

Even if you go on and enable one of background mode like background audio, your app is likely to be rejected during review process as reviewer will see you do not have a valid reason to use that particular background mode. 即使您继续启用诸如背景音频之类的背景模式,您的应用也有可能在审核过程中被拒绝,因为审核者会发现您没有使用特定背景模式的正当理由。

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

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