I have been trying to replicate this feature found in the following app: Charge Alarm
My question is how are they able to access device's battery level when the screen is locked and the app is in the background state?
They send notification when the app is in background state. And they send this notification when device reaches a certain battery level.
NOTE: They are not able to do this if the app is put in background state by pressing home button. But if user locks the screen while the app is active this feature works really good.
I went through this this tutorial
and this seems to be working perfectly. I made only one change, that is, in info.plist file I added a new property Application does not run in background
& gave it a value YES
.