-2

How do I check devices battery level in the background when app is inactive and notify user with certain battery level.

I am a beginner working with swift i have followed Battery Level Solution this solution but it did not worked.

Appreciate your help.

Thanks

HDJEMAI
  • 9,436
  • 46
  • 67
  • 93

2 Answers2

0

Best Solution for this is..

Check the battery consumption rate per time of phone during your application is in working state. And calculate the estimated time for battery to almost drain. Post a local notification at that time. Hope this works unless user switch off his/her phone

Happy coding..

Saranjith
  • 11,242
  • 5
  • 69
  • 122
-1

If your app enters background, it will be suspended if it's not doing things like playing music,recording, etc. So this solution only works when you are in foreground or the app is running in background.

I think you can try to play a silent music when entering background or using the recording api to make system keeps you running even in background. But it may be rejected by appstore if you have no suitable reason to do so in your app.

user3349433
  • 480
  • 2
  • 11
  • If you enable these capabilities, apple may reject your app. Also, even you use it, you still need to add the code to play music or record to make the app keep running. – user3349433 Jun 21 '17 at 08:25