Closed nickelbob closed 5 years ago
Invalid issue template.
Yeah sorry, hit submit accidentally. Filling in details now...
OK, updated details. Let me know how I can help troubleshoot. Thanks for the library - working great on iOS! :)
I’m on vacation until next week but forceReload is incompatible with enableHeadless
Ok - I tried it with forceReload:false and received the same error. I'll keep fiddling with it, have a good vacation and let me know if you have any other ideas about what might be going on. Thanks!
Alright this is interesting - I set forceReload:false and then after I terminated I waited 5+ seconds and then ran the "adb shell cmd jobscheduler run -f com.lazysurfer 999" and it worked! It continued to work everytime I ran the command.
Just to make sure I wasn't crazy I started the app again, terminated and quickly ran the command after that - same issue as above. I tried running it quite a few times after that ( even after 5+ seconds after termination) and it never worked.
So there's some sort of gap between termination and the point at which you can run the "adb shell cmd jobscheduler run -f com.lazysurfer 999" command successfully. Also, if you run the command in this gap it breaks the command until you start the app again.
Perhaps it's related to this error message?
03-09 12:16:38.905 3588 9785 W ActivityManager: Scheduling restart of crashed service com.lazysurfer/com.transistorsoft.rnbackgroundfetch.HeadlessJobService in 1000ms
Ehh, this is not working as well as I thought... I'm not able to consistently trigger the task after termination no matter how long I wait.
The other odd thing is that when I try to relaunch the app after termination + unsuccessful task triggering, the app hangs - it executes my logging statements in index.js but not in the ctor for App.tsx.
@christocracy still struggling with this unfortunately. Lmk if you have any ideas or need any more details. Thanks!
Hey @nickelbob did you by any chance find a solution to this issue? I am trying to build a calendar app with local scheduled notifications which requires a task to be run every 3 hours. In my case I am also facing this issue where if the app is killed the background fetch task is not executed. 😓
@atulmy I did two things that appear to have fixed this - I set enableHeadless = true and I'm using firebase notifications instead of react-native-notifications. Give those a try and if it still doesn't work lemme know and I'll see if I can help.
Unfortunately, enableHeadless: true,
did not work in my case. However it only works if app is foreground/background when not killed.
Android: 9 Pie
Command: adb shell cmd jobscheduler run -f com.example.app 999
I think this issue will only resolve after closing #137 / PR #4 (fixes done by @mason-parachute).
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. You may also mark this issue as a "discussion" and I will leave this open.
Closing this issue after a prolonged period of inactivity. Fell free to reopen this issue, if this still affecting you.
Your Environment
react-native -v
):2.0.1App.tsx
index.js
CheckSpotsInBackgroundTask.tsx
Expected Behavior
When I terminate the app and do "adb shell cmd jobscheduler run -f com.lazysurfer 999" it should run my CheckSpotsInBackgroundTask code
Actual Behavior
Not much. See 'adb logcat' output during "adb shell cmd jobscheduler run -f com.lazysurfer 999" below (note the "sending message to a Handler on a dead thread" and "Calling JS function after bridge has been destroyed")
I also see this when running adb logcat while terminating app -
Steps to Reproduce
Let me know if you're stumped on this and I can try to find a minimal reproducible sample.
Context
This works fine when the app is running or in the background but doesn't work when terminated.
Debug logs
adb logcat while terminated and executing "adb shell cmd jobscheduler run -f com.lazysurfer 999"