MBBatteryMonitor Class Reference
Inherits from | NSObject |
---|---|
Conforms to | MBService |
Declared in | MBBatteryMonitor.h |
Overview
The MBBatteryMonitor
is a service that fires event notifications when
there are changes to device’s battery state, battery level, and plugged-in
status.
When the MBBatteryMonitor
service is running, the service will periodically
fire NSNotification
events with the name “MBBatteryMonitor:update
” whenever
there are status updates to report.
The object
method of the NSNotification
for the “MBBatteryMonitor:update
”
event will return an MBBatteryState
object providing details about the
battery and power state of the device. (Within an MBML <Listener>
, the
MBBatteryState
can be accessed through the expression “$Event.object
”.)
Note: Notification events are posted only when the MBBatteryMonitor
service is running. Use the interface provided by the
MBServiceManager
to ensure that the service is running when
needed.
– currentBatteryState
Determines the current battery state when the MBBatteryMonitor
service
is running.
- (nullable MBBatteryState *)currentBatteryState
Return Value
An MBBatteryState
instance whose properties reflect the
current state of the device’s battery. Will be nil
if the
MBBatteryMonitor
service is not running.
Declared In
MBBatteryMonitor.h