1

I have a React Native Mobile App on Expo that uses location both in background and foreground. But I have a problem because when the app is closed (both on Android and iOS) it continues sending the user location to the server.

I need a way to detect when the App is closed (not backgrounded) to execute 2 actions:

  1. Stop Location Updates
  2. Mutate the userState to offline in the DB

In order to solve the problem I tried multiple solutions:

  • React Native AppStates
  • ComponentWillUnmount
  • Unnoficial libraries like EventLifeCycle Listeners, etc.

Anyone can save me on this one? :)

  • 1
    Closed? Obviously terminated applications cannot send anything as they are not running. – user18309290 Jan 18 '23 at 16:39
  • @user18309290 I have a Background Task that sends the location in background and it continues running after the app is terminated. I'm using this: https://docs.expo.dev/versions/latest/sdk/task-manager/ – Daniel Dias Jan 19 '23 at 09:50

0 Answers0