react-native-background-geolocation-example icon indicating copy to clipboard operation
react-native-background-geolocation-example copied to clipboard

Not working when App closed (Android)

Open dhananjay23 opened this issue 4 years ago • 2 comments

My BackgroundGeolocation configure :

 BackgroundGeolocation.configure({
      desiredAccuracy: BackgroundGeolocation.HIGH_ACCURACY,
      stationaryRadius: 50,
      distanceFilter: 50,
      notificationTitle: 'Background tracking',
      notificationText: 'enabled',
      debug: false,
      startOnBoot: false,
      stopOnTerminate: false,
      locationProvider: BackgroundGeolocation.ACTIVITY_PROVIDER,
      interval: 10000,
      fastestInterval: 5000,
      activitiesInterval: 10000,
      notificationsEnabled:true,
      url: 'http://192.168.81.15:3000/location',
      httpHeaders: {
        'X-FOO': 'bar'
      },
      // customize post properties
      postTemplate: {
        lat: '@latitude',
        lon: '@longitude',
        foo: 'bar' // you can also add your own properties
      }
    });

 BackgroundGeolocation.on('location', (location) => {
      console.log('[ERROR] BackgroundGeolocation ', JSON.stringify(location));
       Alert.alert("Get Location"+ JSON.stringify(location))
});

Not getting location values when the android application is closed not trigger any action in react native side.

dhananjay23 avatar May 13 '20 12:05 dhananjay23

Same here, I'm calling a fetch POST on 'location' event. It only runs while app is open. As soon as I put it in background or lock the device screen, it stops. Running on Samsung Galaxy Tab A.

JuanDeLeon avatar May 25 '20 16:05 JuanDeLeon

You need to use headlessTask no ?

arochedy avatar Jun 09 '20 10:06 arochedy