Introduction
React Native Background Guardian provides a comprehensive API to prevent Android from killing background processes. The library offers methods for managing wake locks, battery optimizations, and OEM-specific settings.Installation
Import Options
You can use either the default export or named exports:TypeScript Support
The library is written in TypeScript and includes complete type definitions. All functions return typed promises:Exported Interfaces
The library exports several TypeScript interfaces for type-safe development:API Categories
Wake Lock Management
Control CPU wake locks to keep background tasks running:acquireWakeLock()- Acquire a partial wake lockreleaseWakeLock()- Release the wake lockisWakeLockHeld()- Check wake lock status
Screen Wake Lock
Keep the screen on while the app is in the foreground:enableScreenWakeLock()- Keep screen ondisableScreenWakeLock()- Allow screen to sleep
Battery Optimization
Manage battery optimization exemptions:isIgnoringBatteryOptimizations()- Check exemption statusrequestBatteryOptimizationExemption()- Request exemptionopenBatteryOptimizationSettings()- Open settings
Power Management
Monitor device power states:isDeviceIdleMode()- Check Doze mode statusisPowerSaveMode()- Check Battery Saver statusopenPowerSaveModeSettings()- Open settings
OEM Settings
Access manufacturer-specific battery settings:openOEMSettings()- Open OEM settingsgetDeviceManufacturer()- Get manufacturer name
Platform Behavior
Most APIs are Android-specific:- Android: Full functionality as documented
- iOS: Most methods are no-ops that return safe default values
Basic Usage Pattern
Error Handling
All methods return boolean promises that resolve tofalse on error rather than throwing exceptions. This makes error handling straightforward:

