Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to determine battery related info of iOS device programmatically?

Tags:

ios

iphone

I'm implementing iOS application in which I want to check battery information, like battery status, current battery level, is charging plugged in or not, etc. I did all this, but I want more info about battery like battery temperature, battery health, battery scale, battery technology. All this information is available in android, but can anyone help me to have all these info in iOS?

like image 221
Trup Avatar asked Nov 12 '12 11:11

Trup


1 Answers

Try this

         [[UIDevice currentDevice] setBatteryMonitoringEnabled:YES];
        float batteryLevel = [[UIDevice currentDevice] batteryLevel];

        //This will give you the battery between 0.0 (empty) and 1.0 (100% charged)
       //If you want it as a percentage, you can do this:

      batteryLevel *= 100;
like image 165
Ramz Avatar answered Oct 17 '22 00:10

Ramz