Skip to main content

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

success
boolean
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

Google Play has strict restrictions on apps requesting this permission.Only use this API if your app genuinely requires background execution:
  • ✅ Messaging apps
  • ✅ Health/fitness tracking
  • ✅ Device management/enterprise apps
  • ✅ Accessibility services
  • ✅ Alarm/reminder apps
Apps that don’t meet Google’s acceptable use cases may be rejected or removed from the Play Store.See Google Play Policy for details.

Permission Required

This method requires the REQUEST_IGNORE_BATTERY_OPTIMIZATIONS permission in your AndroidManifest.xml:
This permission is automatically added by the library.

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, use openBatteryOptimizationSettings() instead:
This approach:
  • ✅ Doesn’t require REQUEST_IGNORE_BATTERY_OPTIMIZATIONS permission
  • ✅ Complies with Google Play policies
  • ❌ Requires more user steps (they must find your app in the list)