React Native library that provides methods for checking Low Power Mode on iOS and Power Saver/Battery Saver Mode on Android, as well as navigating to the Power Saver/Battery Saver Mode settings on Android.
| Android | iOS |
![]() |
To install the library, use either npm or yarn:
npm install react-native-power-saver-detector
# or
yarn add react-native-power-saver-detector
For React Native 0.60 and above, the library should be automatically linked. For older versions, you will need to link the library manually:
react-native link react-native-power-saver-detector
For iOS, don't forget to run pod install after linking the library:
cd ios && pod install
| Method | Description | Platform |
|---|---|---|
isLowPowerModeEnabled |
Checks if Low Power Mode is enabled on iOS. | iOS |
isPowerSaverModeEnabledSync |
Synchronously checks if Power Saver Mode is enabled on Android. | Android |
isPowerSaverModeEnabled |
Asynchronously checks if Power Saver Mode is enabled on Android. | Android |
openPowerSaverSettings |
Navigates to the Power Saver Mode settings on Android. | Android |
Checks if Low Power Mode is enabled on iOS.
Promise<boolean | null>: A promise that resolves to true if Low Power Mode is enabled, false if not, and null if the check fails. This might return null if the system information is unavailable or an error occurs during the check.
import { PowerSaverDetector } from 'react-native-power-saver-detector';
PowerSaverDetector.isLowPowerModeEnabled().then((isEnabled) => {
console.log('Low Power Mode enabled:', isEnabled);
});
Synchronously checks if Power Saver Mode is enabled on Android.
boolean | null: Returns true if Power Saver Mode is enabled, false if not, and null if the PowerManager service is unavailable. This might return null if the PowerManager service is not available on the device or an error occurs during the check.
import { PowerSaverDetector } from 'react-native-power-saver-detector';
const isEnabled = PowerSaverDetector.isPowerSaverModeEnabledSync();
console.log('Power Saver Mode enabled (sync):', isEnabled);
Asynchronously checks if Power Saver Mode is enabled on Android.
Promise<boolean | null>: A promise that resolves to true if Power Saver Mode is enabled, false if not, and null if the PowerManager service is unavailable. This might return null if the PowerManager service is not available on the device or an error occurs during the check.
import { PowerSaverDetector } from 'react-native-power-saver-detector';
PowerSaverDetector.isPowerSaverModeEnabled().then((isEnabled) => {
console.log('Power Saver Mode enabled (async):', isEnabled);
});
Navigates to the Power Saver Mode settings on Android.
import { PowerSaverDetector } from 'react-native-power-saver-detector';
PowerSaverDetector.openPowerSaverSettings();
Contributions are welcome! Please open an issue or submit a pull request to discuss any changes.
This project is licensed under the MIT License.
