-
Notifications
You must be signed in to change notification settings - Fork 195
Open
Labels
Description
Required Reading
- Confirmed
Plugin Version
4.1.10
Mobile operating-system(s)
- iOS
- Android
Device Manufacturer(s) and Model(s)
Various Android devices
Device operating-systems(s)
Android (various versions)
React Native / Expo version
React Native 0.76.9
What happened?
Description
I'm experiencing a SecurityException crash related to a missing WAKE_LOCK permission when using react-native-background-fetch on Android.
Error Stack Trace
java.lang.RuntimeException: Unable to start receiver com.transistorsoft.tsbackgroundfetch.FetchAlarmReceiver: java.lang.SecurityException: Neither user 10221 nor current process has android.permission.WAKE_LOCK.
at android.app.ActivityThread.handleReceiver(ActivityThread.java:5038)
at android.app.ActivityThread.-$$Nest$mhandleReceiver(unknown:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2577)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loopOnce(Looper.java:248)
at android.os.Looper.loop(Looper.java:338)
at android.app.ActivityThread.main(ActivityThread.java:9067)
Expected Behavior
The background fetch should work without throwing a SecurityException.
Questions for Maintainer
-
Should I manually add the WAKE_LOCK permission to my AndroidManifest.xml? Would adding this permission resolve the issue?
-
Is this permission missing from the README/documentation? I noticed this permission requirement isn't clearly documented in the setup instructions.
-
If this permission is required, should it be:
- Automatically included by the library?
- Explicitly documented in the installation/setup guide?
Additional Context
This seems to be occurring when the FetchAlarmReceiver attempts to start but lacks the necessary WAKE_LOCK permission.
Plugin Code and/or Config
let status = await BackgroundFetch.configure(
{
minimumFetchInterval:
backgroundFetchConfig?.minimumFetchInterval ?? 15,
scheduleTask: true,
stopOnTerminate: false,
startOnBoot: true,
enableHeadless: true,
},
onEvent,
onTimeout,
);