Closed OliEfr closed 4 years ago
@OliEfr did you find a fix for this?? I keep getting:
08-21 19:06:41.895 28801 28801 D BackgroundTask: Setting foreground false
08-21 19:06:41.895 28801 28801 D BackgroundTask: Committing job schedule
08-21 19:06:47.051 28801 28801 D ReactNative: ReactInstanceManager.detachViewFromInstance()
I think the ReactInstanceManager.detachViewFromInstance() prevents the job from running in my case.
No, I ended up using a different package. React-Native-Background-Job I think.
and did it work even for Android 10?? @OliEfr
It heavily depends on the phone and specific OS. You might need to prompt for battery permission etc.
Unfortunately, I found no easy one for all solution.
I developed an app on Huawei Honor 5c (Android Version 4.0 - 7.0?), which worked perfectly fine with react-native-background task.
I switched the phone (Xiaomi Mi 9SE (MIUI Global 11.0.6 / Android 9) with the same project. The background task still executes when the app is in background unclosed. As soon as the app is killed, the task does not fire anymore. adb logcat logging does not show any (error) messages.
For Android 10, the background task does not fire at all, also when the app is left open in background.
I tried to find workarounds and tried other packages as well (react-native-background-jobs, react-native-background-fetch). However, none of this worked.
Unfortunately, I am new to Android programming and didn't find any related issues so far.
Did the headless implementation change with new android versions? Do I need to change something in my project for use with Android 9/10? Is there a way for better testing this issue? Do i need to write java code? I dont understand why it worked on previous Android versions.
react-native version: 0.61.4 react-native-background-task: 0.2.1