简体   繁体   中英

iOS: keep task running when in sleep mode

I'm trying to develop a little app in order to learn coding for iOS. The app needs to check the battery level every minute and accordingly send an HTTP request. This works when the app is awake.

How can I make it run when the device is put in sleep mode?

The short answer is you can't, or at least shouldn't. Apple doesn't allow apps to run in the background for extended periods of time with a few exceptions like navigation apps, VoIP apps and a few others (a full list can be found here ). I recommend that you read about UIBackgroundModes and the app lifecycle in the link I attached.

Happy coding!

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