Overview
Opens the system dialog to request battery optimization exemption. This allows the user to whitelist the app from Doze mode and App Standby restrictions.Returns
Promise resolving to
true if the dialog was shown, false if the dialog couldn’t be opened or the app is already exempt.Platform Behavior
Google Play Policy Warning
Permission Required
This method requires theREQUEST_IGNORE_BATTERY_OPTIMIZATIONS permission in your AndroidManifest.xml:
Important Notes
- User Approval Required: The user must manually tap “Allow” in the system dialog. The app cannot force exemption.
- Already Exempt: If the app is already ignoring battery optimizations, the dialog won’t be shown and the method returns
true. - Check First: Use
isIgnoringBatteryOptimizations()to check before requesting. - Alternative: Consider using
openBatteryOptimizationSettings()instead, which doesn’t require special permission.
Example Usage
Basic Request
Check Before Requesting
With User Explanation
Onboarding Flow
Settings Screen
With Error Handling
Alternative Approach
If you want to avoid Google Play policy concerns, useopenBatteryOptimizationSettings() instead:
- ✅ Doesn’t require
REQUEST_IGNORE_BATTERY_OPTIMIZATIONSpermission - ✅ Complies with Google Play policies
- ❌ Requires more user steps (they must find your app in the list)
Related APIs
isIgnoringBatteryOptimizations()- Check exemption statusopenBatteryOptimizationSettings()- Open settings list (alternative)openOEMSettings()- Open OEM-specific settings

