For iOS projects, install the native dependencies using CocoaPods:
cd ios && pod install
On iOS, all library methods are no-ops that return safe default values. iOS handles background execution differently through Background Modes, so no additional configuration is needed.
No additional setup is required for Android. The necessary permissions are automatically merged into your app’s manifest:
<!-- Required for Wake Lock functionality --><uses-permission android:name="android.permission.WAKE_LOCK" /><!-- Required for requesting battery optimization exemption --><uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
The REQUEST_IGNORE_BATTERY_OPTIMIZATIONS permission is restricted by Google Play. Your app must fall into specific acceptable use cases (messaging, health tracking, task automation, etc.) to use this permission. See the Introduction page for the full list of acceptable use cases.
After installation, verify that the library is working by importing it in your code:
import BackgroundGuardian from 'react-native-background-guardian';// Check if the module is availableconst manufacturer = await BackgroundGuardian.getDeviceManufacturer();console.log('Device manufacturer:', manufacturer);
After installing the library, rebuild your app to ensure native modules are linked properly:
npx react-native run-android
npx react-native run-ios
If you encounter any issues during installation, try cleaning your build:Android:cd android && ./gradlew cleaniOS:cd ios && rm -rf build && pod install