Quick start guide
This guide will walk you through the basic setup and usage of React Native Background Guardian to ensure your app can run reliably in the background on Android devices.Install the library
Add React Native Background Guardian to your project:For iOS projects, install pods:
Import and use wake locks
Import the library and use wake locks to keep the CPU running during background tasks:
Check battery optimization status
Check if your app is exempt from battery optimizations and request exemption if needed:
Handle OEM-specific settings
Many Android manufacturers have additional battery optimization settings. Guide users to these settings for devices with aggressive battery management:
The library supports OEM settings for Xiaomi, Samsung, Huawei, Honor, OnePlus, Oppo, Vivo, Realme, Asus, and more. For unsupported manufacturers, it falls back to standard battery optimization settings.
Complete example
Here’s a complete example using a React hook to manage background guardian functionality:Common use cases
Background audio player
Foreground kiosk mode
Next steps
API Reference
Explore all available methods and their parameters
Android Doze Mode
Learn how to survive Android’s battery optimization features

