简体   繁体   中英

Does a background iOS app receive notification that the display is going to sleep?

My specific requirement is an app that is in the background, being notified that the display is about to go to sleep or that the device has or is about to reach it's idle timeout - and then waking up and executing some (brief) piece of code.

I have found reference to notifications that an app is being put in the background or suspended here: http://developer.apple.com/library/ios/#DOCUMENTATION/iPhone/Conceptual/iPhoneOSProgrammingGuide/ManagingYourApplicationsFlow/ManagingYourApplicationsFlow.html

And there seems to be a way of detecting on OSX: http://developer.apple.com/library/mac/#qa/qa1340/_index.html

So, can a background iOS app receive notification that the display is going to sleep and execute just before it does?

No, thats not possible on iOS. I suggest you file a bug report at bugreport.apple.com and explain to them why you need such a feature, although this isn't a guarantee that such a thing will come. But if more people request this feature, the likelier it gets implemented.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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