react-native-background-geolocation-example
react-native-background-geolocation-example copied to clipboard
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.
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.
You need to use headlessTask no ?