When is Device Connected to Power?

Is there a way to tell if the device is connected to power?

There’s an example included with Xojo in the iOS > Declares folder which will allow you to do just this. Check out the UIDevice project.

can register for the notification as well rather than polling it
https://developer.apple.com/documentation/foundation/nsprocessinfopowerstatedidchangenotification?language=objc

The app always returns Battery Monitoring is not enabled and the class does not appear to actually be able to set that. So how does one go about enabling the Battery Monitoring?

Is this on an actual device? It may not work in the simulator. Once batteryMonitoringEnabled is true, batteryState should tell you the actual state.

Yes. An iPod Touch.

I’m not at my computer right now but batteryMonitoringEnabled (which defaults to false) should probably be a computed property. The setter should be something like this:

// Untested Declare Sub setBatteryMonitoringEnabled lib "UIKIT" selector "batteryMonitoringEnabled"(o as Ptr, value as Boolean) setBatteryMonitoringEnabled(UIDevice.device.handle, status)

Maybe

// Untested Declare Sub setBatteryMonitoringEnabled lib "UIKIT" selector "setBatteryMonitoringEnabled:"(o as Ptr, value as Boolean)

Yes! That worked. Thank you SO much for the help.