Not working when App closed (Android)
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.
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.
@dhananjay23 also, make sure that you have location permission set as "Allow all the time" (not only "While using the app") on API29+
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.
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' ................ }
any update?