🔋An iOS battery monitor library
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Battery
Sample
Battery.podspec
LICENSE
README.md

README.md

Battery

Battery is an easy-to-use class to monitor battery status on iOS.

Also see MXBatteryMointor for Objective-C version.

Installation

CocoaPods

pod 'Battery'

Usage

import Battery
Battery.mointor.onBatteryStateChanged = { (state) in
  print("State: " + state.stringValue)
}

Battery.mointor.onBatteryLevelChanged = { (level) in
  print("Level: " + (level.percentString() ?? "Unknown"))
}
Battery.mointor.start()
let level = Battery.mointor.batteryLevel
let state = Battery.mointor.batteryState
let levelString = Battery.mointor.batteryLevelString
let stateString = Battery.mointor.batteryStateString
Battery.monitor.stop()