react-native-device-battery
Get and observe the devices battery level and charging status
Installation
Install the node module
npm install react-native-device-battery --save
iOS
TBD
Android
Add the following to android/settings.grade
include ':react-native-device-battery'
project(':react-native-device-battery').projectDir = new File(settingsDir, '../node_modules/react-native-device-battery/android')
Add the following to android/app/build.gradle
compile project(':react-native-device-battery')
Register the module in MainActivity.java
// <--- import
Example Usage
; // get the battery levelDeviceBattery; // check if the device is chargingDeviceBattery; // as a listenervar { console // {level: 0.95, charging: true}}; // to attach a listenerDeviceBattery; // to remove a listenerDeviceBattery;