Reputation: 2257
Is it possible to have an app in the background notified when an iOS device is plugged in to or unplugged from power?
Upvotes: 0
Views: 150
Reputation: 410
You need two functions:
CFRunLoopSourceRef IOPSNotificationCreateRunLoopSource(IOPowerSourceCallbackType callback, void *context);
// to subscrive to a notification of a power source being changed
and
CFTypeRef IOPSCopyPowerSourcesInfo(void);
// to get info about your current power source
Both are described here: IOPowerSource
I'm not sure is it going to work in background mode or not, but you can try.
Upvotes: 1