Documentation Index
Fetch the complete documentation index at: https://mintlify.com/ivangonzalezg/react-native-background-guardian/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Enables a screen wake lock to keep the display on while the app is in the foreground. This is different from CPU wake locks and does NOT keep background tasks running.Returns
Promise resolving to
true if the screen wake lock was enabled, false otherwise.Platform Behavior
| Platform | Behavior |
|---|---|
| Android | Sets FLAG_KEEP_SCREEN_ON on the current Activity window. The screen stays on only while the app is visible. |
| iOS | Disables the idle timer (UIApplication.shared.isIdleTimerDisabled = true). The screen stays on while the app is active. |
Important Notes
- Foreground Only: This keeps the screen awake only while the app is in the foreground. It does NOT replace
acquireWakeLock()for background CPU execution. - Activity Required: On Android, this requires a current Activity. Returns
falseif no Activity is available. - Battery Impact: Keeping the screen on consumes significant battery. Use sparingly and only when necessary.
- Automatic Cleanup: The system automatically clears this when the Activity is destroyed.
Use Cases
✅ Good use cases:- Video playback
- Navigation/maps display
- Reading/viewing content
- Live monitoring dashboards
- Camera preview screens
- Background task execution (use
acquireWakeLock()instead) - When the app is in the background
- Battery-sensitive scenarios
Example Usage
Basic Usage
Video Player Component
Navigation Screen
Conditional Screen Lock
With Error Handling
Comparison with CPU Wake Lock
| Feature | enableScreenWakeLock() | acquireWakeLock() |
|---|---|---|
| Purpose | Keep screen on | Keep CPU running |
| Works when | App is visible | Background + foreground |
| Battery impact | High (screen on) | Medium (CPU running) |
| Use for | User-facing content | Background processing |
| iOS support | Yes (idle timer) | No (not applicable) |
Related APIs
disableScreenWakeLock()- Allow screen to turn offacquireWakeLock()- Keep CPU running (different purpose)

