Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS - Programatically get battery usages of an application

I want to get battery usages of an application programmatically. iOS 8 provide battery usages monitor utility and I want to know how did Apple implemented this feature. Is there any public API for this ?

I want battery consumption value for my iOS app in x mAh/min or x% of current battery status or any similar format.

Kindly help.

like image 686
Santosh Kumar Avatar asked May 13 '15 08:05

Santosh Kumar


1 Answers

You can do if you follow the below code

 if (![[UIDevice currentDevice] isBatteryMonitoringEnabled])
 {
   [[UIDevice currentDevice] setBatteryMonitoringEnabled:YES];
 }
 NSLog(@"battery : %f", [[UIDevice currentDevice] batteryLevel]);

Also there is some link for your question - How to get real time battery level on iOS with a 1% granularity

like image 109
user3182143 Avatar answered Oct 21 '22 13:10

user3182143