Trup
Trup

Reputation: 635

How to determine battery related info of iOS device programmatically?

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?

Upvotes: 6

Views: 2502

Answers (1)

Ramz
Ramz

Reputation: 596

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;

Upvotes: 4

Related Questions