mauron85 / react-native-background-geolocation-example

Example app of react-native-mauron85-background-geolocation component.
120 stars 45 forks source link

Not working when App closed (Android) #19

Open dhananjay23 opened 4 years ago

dhananjay23 commented 4 years ago

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.

JuanDeLeon commented 4 years ago

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.

arochedy commented 4 years ago

You need to use headlessTask no ?