How do I get the battery status on an iPhone?
Here's what I used for my string as a quick utility method, note that you have to enable battery monitoring to get a value, and then if you don't want to get the notifications (obviously some efficiency to be gained there, since they give you the ability to turn it off) then you should turn it off again after (like I do in this function):
NSString *statusString(void)
{
UIDevice *device = [UIDevice currentDevice];
NSString *batteryStateString = nil;
switch(device.batteryState)
{
case UIDeviceBatteryStateUnplugged: batteryStateString = @"Unplugged"; break;
case UIDeviceBatteryStateCharging: batteryStateString = @"Charging"; break;
case UIDeviceBatteryStateFull: batteryStateString = @"Full"; break;
default: batteryStateString = @"Unknown"; break;
}
[device setBatteryMonitoringEnabled:YES];
NSString *statusString = [NSString stringWithFormat:@"Battery Level - %d%%, Battery State - %@",
(int)round(device.batteryLevel * 100), batteryStateString];
[device setBatteryMonitoringEnabled:NO];
return statusString;
}