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

Not working when App closed (Android)

Open dhananjay23 opened this issue 5 years ago • 5 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

Make sure you have foreground notification active when closing the app.

Also double check that you not calling BackgroundGeolocation.stop(); somewhere on componentWillUnmount for example, recently I did same mistake.

chugunomi avatar May 15 '20 07:05 chugunomi

@dhananjay23 also, make sure that you have location permission set as "Allow all the time" (not only "While using the app") on API29+

chugunomi avatar May 19 '20 11:05 chugunomi

I will check BackgroundGeolocation.stop() not place anywhere and Foreground notification is also enabled in android but not get location values in BackgroundGeolocation.on('location', (location)) method.

dhananjay23 avatar May 22 '20 04:05 dhananjay23

put manual in android/settings.gradle include ':@mauron85_react-native-background-geolocation-common' project(':@mauron85_react-native-background-geolocation-common').projectDir = new File(rootProject.projectDir, '../node_modules/@mauron85/react-native-background-geolocation/android/common') include ':@mauron85_react-native-background-geolocation' project(':@mauron85_react-native-background-geolocation').projectDir = new File(rootProject.projectDir, '../node_modules/@mauron85/react-native-background-geolocation/android/lib')

and put in app/build.gradle dependencies { ............ implementation 'com.google.android.gms:play-services-gcm:15.0.1' implementation 'com.google.android.gms:play-services-location:15.0.1' ................ }

cioletti avatar Jun 05 '20 19:06 cioletti

any update?

lyseiha avatar Aug 04 '20 14:08 lyseiha