expo / expo

An open-source framework for making universal native apps with React. Expo runs on Android, iOS, and the web.
https://docs.expo.dev
MIT License
30.1k stars 4.72k forks source link

[docs] expo-location and expo-task-manager #28631

Open srinivasbevara opened 3 weeks ago

srinivasbevara commented 3 weeks ago

Summary

Hello,

I need to continuously track the user's live location in my app. I've implemented this functionality using expo-location and expo-task-manager, following a reference example. After deploying the app to the Google Play Store and conducting tests, we discovered that while the app is in the foreground, we successfully receive the user's live location. However, when the app is minimized or running in the background, we no longer receive live location updates. Could you provide any guidance or reference code to ensure that we can consistently obtain the user's live location even when the app is running in the background?

background-fetch: We've implemented background-fetch to retrieve the user's live location every minute while the app is running in the background. However, our goal is to receive location updates at least every 10 seconds.

Reference code:

https://docs.expo.dev/versions/latest/sdk/task-manager/ https://docs.expo.dev/versions/latest/sdk/background-fetch/

https://arnav25.medium.com/background-location-tracking-in-react-native-d03bb7652602#:~:text=The%20task%20of%20location%20tracking,or%20stop%20tracking%20your%20location.

Link to the related docs page

https://docs.expo.dev/versions/latest/sdk/task-manager/

Anything else?

No response

choutianxius commented 3 weeks ago

I was facing the same issue. Found out that the JavaScript process might be suspended by the OS when the app is not in foreground, so probably nothing can be done on the Expo end. My solution was to cache the collected GPS data and send them when possible.