Unable to make a fetch when app is running in background
See original GitHub issueI have configured a background task in android and i want it to be triggered every 15mins irrespective of the app state. im using both configure and registerHeadlessTask
BackgroundFetch.configure({
minimumFetchInterval: 15, // <-- minutes (15 is minimum allowed)
stopOnTerminate: false, // <-- Android-only,
enableHeadless: true // <-- Android-only
},task, (error) => {
console.log("[js] RNBackgroundFetch failed to start ::::", err);
});
BackgroundFetch.registerHeadlessTask(task);
Your Environment
- Plugin version: 2.5.6
- Platform: Android
- React Native version (
react-native -v
): 0.57.7
Expected Behavior
background task should work when the app is running in background or even when it is killed
Actual Behavior
the background task is working when the app is not running, but when the app is in running in the background, the task is triggered but then fetch is not happening and I get the response when I open the app
Context
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:16 (6 by maintainers)
Top Results From Across the Web
Unable to ensure Background Fetch is enabled in my app
Hi all as titled, I am creating an app (Lets give this app name as 'TM'). TM is a GPS Location Navigatator app...
Read more >Error fetch when App is put in background - Stack Overflow
Recently fell into this issue. Sometimes network request fails on iOS when app is in background. https://developer.apple.com/forums/thread/ ...
Read more >react-native-background-fetch - npm
Background Fetch is a very simple plugin which attempts to awaken an app in the background about every 15 minutes, providing a short...
Read more >How to run code when your app is terminated
To try this out, hold down the Alt key then go to the Product menu and choose “Run…”. This will let you edit...
Read more >background_fetch | Flutter Package - Pub.dev
Background Fetch is a very simple plugin which will awaken an app in the background about every 15 minutes, providing a short period...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @christocracy, we do have the same problem like @gghnisan. The headlessjs task does not run if the app is killed.
Some logs:
Here is a repo with simple repro app. https://github.com/skaldo/BackgroundFetchBug
Device is Samsung Galaxy S8 running Android 9.
Could you please check if there’s something wrong with the code? Just run it with
react-native run-android --variant=release
, signing is configured. Thanks!Closing this issue after a prolonged period of inactivity. Fell free to reopen this issue, if this still affecting you.