I would like to know if my app is running with an external power cable attached. Is it possible to find out this state at runtime?
An extra question: would this be able
You can detect whether the battery is charging, but that's as close as you can get with existing APIs – there's no way to detect where the power is "coming from", so to speak.
UIDeviceBatteryState batteryState = [UIDevice currentDevice].batteryState;
if (batteryState == UIDeviceBatteryStateCharging) {
// Your code here
}