Wake lock not working
Issue: Wake lock appears to be acquired but background tasks still stop
Possible causes:-
Testing on emulator instead of real device
- Emulators may not accurately simulate Doze mode and power management
- Always test wake lock functionality on physical devices
-
Wake lock timeout expired
- Default timeout is 24 hours (86,400,000 ms)
- Wake lock is automatically released after timeout to prevent battery drain
-
Wake lock not actually acquired
- Check return value from
acquireWakeLock()
- Check return value from
- Check if the app has
WAKE_LOCKpermission - Verify
acquireWakeLock()returnedtrue - Ensure the app wasn’t force-stopped by the user
Issue: Wake lock released too early
Common causes:- Multiple calls to
releaseWakeLock()- Each
acquireWakeLock()call should have exactly one matchingreleaseWakeLock()call
- Each
- App crashed or was killed
- Wake locks are automatically released if the app process is killed
- Battery optimization killed the app
- Device is not exempt from battery optimizations
- See Battery optimization not updating
Battery optimization status not updating
Issue: App shows as not exempt even after user grants exemption
After the user accepts or rejects the battery optimization dialog, the app is taken to the system settings. The status won’t update until the app returns to the foreground. Solution: UseAppState to refresh status when app becomes active:
Issue: Exemption granted but app still killed in background
Battery optimization exemption only covers Doze mode. Other factors can still kill your app:-
Power Save mode is enabled
- Affects ALL apps regardless of exemptions
- Check with
isPowerSaveMode()and prompt user to disable it
-
OEM-specific battery optimization not disabled
- Xiaomi, Huawei, Samsung, etc. have additional battery savers
- See OEM settings not opening
-
App Standby restrictions
- Use a Foreground Service for continuous operation
- Consider libraries like
react-native-background-actions
Battery optimization exemption alone is often not enough on devices from Xiaomi, Huawei, Oppo, Vivo, and OnePlus. Always check for OEM-specific settings.
OEM settings not opening
Issue: openOEMSettings() returns false or opens wrong page
Some OEM activities may not exist on all device variants or OS versions. The library attempts to open multiple activities per manufacturer and falls back gracefully.
Solution:
-
Check device manufacturer
-
Test fallback behavior
-
Manual instructions for unsupported devices
Supported OEM manufacturers
| Manufacturer | Status | Notes |
|---|---|---|
| Xiaomi (MIUI) | ✅ Supported | Multiple fallback activities |
| Samsung (OneUI) | ✅ Supported | Works on most variants |
| Huawei (EMUI) | ✅ Supported | May vary by EMUI version |
| Honor (Magic UI) | ✅ Supported | Uses Huawei settings |
| Oppo (ColorOS) | ✅ Supported | Settings path may differ |
| Vivo (FuntouchOS) | ✅ Supported | Settings path may differ |
| OnePlus (OxygenOS) | ✅ Supported | Similar to Oppo |
| Realme (Realme UI) | ✅ Supported | Similar to Oppo |
| Other | ⚡ Fallback | Opens standard battery settings |
Google Play policy considerations
Issue: App rejected for using REQUEST_IGNORE_BATTERY_OPTIMIZATIONS
Google Play restricts use of the REQUEST_IGNORE_BATTERY_OPTIMIZATIONS permission to specific app categories.
Acceptable use cases:
| App Type | Description |
|---|---|
| Chat / Voice / Video | Apps needing real-time messaging where FCM High Priority is insufficient |
| Task Automation | Apps that schedule automated actions (macros) |
| Health / Fitness | Tracking workouts, often combined with Foreground Service |
| Device Connection | Companion apps for smartwatches, IoT devices, etc. |
| Safety | Apps for personal safety (SOS) |
| VPN / Proxy | Network tools |
-
Remove the permission from AndroidManifest.xml
-
Use
openBatteryOptimizationSettings()insteadThis opens the system list where users can manually select “Don’t optimize” for your app. It requires more user steps but doesn’t require special permissions. -
Update your app’s Play Store listing
- Clearly explain why your app needs background execution
- Provide screenshots of the exemption process
- Document legitimate use cases
openBatteryOptimizationSettings() doesn’t require the REQUEST_IGNORE_BATTERY_OPTIMIZATIONS permission and is safe to use in all apps.Issue: Play Store warning about battery drain
If Google Play flags your app for excessive battery usage:-
Always release wake locks when done
-
Use appropriate timeouts
-
Consider Foreground Services
- Shows persistent notification
- Signals to user and system that app is active
- Better user experience than invisible background execution
Platform-specific issues
Android version compatibility
Android < 6.0 (API 23)- Battery optimization APIs not available
- Methods return safe defaults
- Wake locks still work
- Basic Doze mode support
- App Standby restrictions
- Battery optimization exemptions work
- Enhanced battery optimization
- Stricter background execution limits
- App Standby buckets
iOS limitations
All methods are no-ops on iOS that return safe default values:- Background Modes (audio, location, fetch, etc.)
- Push notifications
- Background App Refresh
- Silent push notifications
Configure appropriate Background Modes in your iOS app’s Info.plist instead of using wake locks.
Getting help
If you encounter issues not covered here:-
Enable verbose logging
-
Check ADB logs
-
Test on multiple devices
- Different manufacturers behave differently
- Test on Xiaomi, Samsung, and stock Android if possible
-
Report issues
- Include device manufacturer and OS version
- Provide ADB logs
- Describe steps to reproduce

