Closed ifgabriel closed 5 months ago
exit the application
What code are you expecting to execute after terminate?
I create a task and after leaving the application, it stays in the background, it must execute a task every 1 minute (the minimum time) and this should be carried out in a loop until I finish a task, right?
Paste the specific code that you expect to execute after app terminate.
My code is just the above, what do you mean by code after finishing? I create an activity with periodic true, shouldn't it continue until I finish it?
After terminating an Android app, none of your code above is going to run..
Read the API docs enableHeadless
Also read the Debugging section.
The application is not terminated, just placed in the background
It's up to the OS to fire events. See https://dontkillmyapp.com
If a task stops running, it's the OS doing that to preserve the device battery and there's nothing the plug-in can do to stop that.
I don't know if you can help me. But I need my user (restricted use) to send me their location every 20 seconds, I capture the location with Google's Gelocalition and send it to an API in my backend. However, I am facing the problem of running background tasks on Android. And I'm wondering how this location service works so well in the Uber, Ifood, WhatsApp apps. Can you tell me if they use another approach?
You will never succeed attempting to get the location every 20s, particularly with the most recent Android 14.
The best you'll get is periodic requests about every 15 minutes.
Your best hope is to try using my react-native-background-geolocation (non-free): https://www.transistorsoft.com/shop/products/react-native-background-geolocation
This library tracks location when the device is determined to be moving.
Your Environment:
Code
Expected Behavior
It should run without interruptions
Actual Behavior
After 30 minutes the task stops running
Steps to Reproduce
Context
I'm trying to update device coordinates even with the app running in the background
Debug logs
[Wed Nov 01 2023 10:22:26.640] LOG [BackgroundFetch] configure status: 2 [Wed Nov 01 2023 10:23:24.228] LOG [BackgroundFetch] task: UPDATE_COORDINATES [Wed Nov 01 2023 10:24:24.228] LOG [BackgroundFetch] task: UPDATE_COORDINATES [Wed Nov 01 2023 10:25:24.227] LOG [BackgroundFetch] task: UPDATE_COORDINATES ............
[Wed Nov 01 2023 10:50:24.228] LOG [BackgroundFetch] task: UPDATE_COORDINATES [Wed Nov 01 2023 10:51:24.230] LOG [BackgroundFetch] task: UPDATE_COORDINATES