How to detect from an iPhone app whether iPhone battery is in charging or not?

In my iPhone app, there is a requirement to know whether the iphone is charging or not?

If it is charging then I want to display alert for the same.

So how can I detect whether the iphone is Charging or not?

What should I do?

Please Help and Suggest.



[[UIDevice currentDevice] setBatteryMonitoringEnabled:YES];

if ([[UIDevice currentDevice] batteryState] != UIDeviceBatteryStateUnplugged) {
    //Device is connected (charging or fully charged)

Edit: If you relly want to check if the device is charging (and not 100% full yet), use the UIDeviceBatteryStateCharging constant in the if statement. See the documentation for more information.

Need Your Help

Why Delphi objects that implement interfaces need to be reference counted?

delphi interface com

In other words, why can't they be manually managed like a regular object? Or Did the Delphi designers just decided to use reference counting since it was needed for COM anyways?

How do I create an Atom representation with Restlet?

java rss atom restlet rome

I want to create atom xml representations for my REST resources using Restlet.