Reputation: 1357
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?
Upvotes: 0
Views: 1546
Reputation: 2877
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!
Upvotes: 1