react-native-background-geolocation
react-native-background-geolocation copied to clipboard
Can't fetch location in background after 2-3 hours
This plugin stop fetching location after 2-3 hours in background
Your Environment
- Plugin version: 0.6.3
- Platform: Android
- OS version: Android 10
- Device manufacturer and model: Nokia 6.1 Plus
- React Native version: 0.61.5
Context
I want to fetch user location continuously (every 1 minute) in background for a long time and this plugin does not fetch location after 2-3 hours
Expected Behavior
It should fetch location every minute even in background
Actual Behavior
Possible Fix
Can use foreground service to fetch location
Also when i try to use headlessTask , then got following error
WARN registerHeadlessTask or registerCancellableHeadlessTask called multiple times for same key 'com.marianhello.bgloc.react.headless.Task'
This plugin stop fetching location after 2-3 hours in background
Your Environment
- Plugin version: 0.6.3
- Platform: Android
- OS version: Android 10
- Device manufacturer and model: Nokia 6.1 Plus
- React Native version: 0.61.5
Context
I want to fetch user location continuously (every 1 minute) in background for a long time and this plugin does not fetch location after 2-3 hours
Expected Behavior
It should fetch location every minute even in background
Actual Behavior
Possible Fix
Can use foreground service to fetch location
Also when i try to use headlessTask , then got following error
WARN registerHeadlessTask or registerCancellableHeadlessTask called multiple times for same key 'com.marianhello.bgloc.react.headless.Task'
Can you share your code ?
This plugin stop fetching location after 2-3 hours in background
Your Environment
- Plugin version: 0.6.3
- Platform: Android
- OS version: Android 10
- Device manufacturer and model: Nokia 6.1 Plus
- React Native version: 0.61.5
Context
I want to fetch user location continuously (every 1 minute) in background for a long time and this plugin does not fetch location after 2-3 hours
Expected Behavior
It should fetch location every minute even in background
Actual Behavior
Possible Fix
Can use foreground service to fetch location Also when i try to use headlessTask , then got following error WARN registerHeadlessTask or registerCancellableHeadlessTask called multiple times for same key 'com.marianhello.bgloc.react.headless.Task'
Can you share your code ?
BackgroundGeolocation1.configure({
desiredAccuracy: BackgroundGeolocation1.HIGH_ACCURACY,
stationaryRadius: 50,
distanceFilter: 50,
notificationTitle: 'Background tracking',
notificationText: 'enabled',
debug: false,
startOnBoot: false,
stopOnTerminate: false,
locationProvider: BackgroundGeolocation1.ACTIVITY_PROVIDER,
interval: 30000,
fastestInterval: 5000,
activitiesInterval: 10000,
notificationsEnabled:true,
url: '',
httpHeaders: {
'X-FOO': 'bar'
},
// customize post properties
postTemplate: {
lat: '@latitude',
lon: '@longitude',
foo: 'bar' // you can also add your own properties
}
});
BackgroundGeolocation1.checkStatus(status => {
console.log('[INFO] BackgroundGeolocation service is running', status.isRunning);
console.log('[INFO] BackgroundGeolocation services enabled', status.locationServicesEnabled);
console.log('[INFO] BackgroundGeolocation auth status: ' + status.authorization);
// you don't need to check status before start (this is just the example)
if (!status.isRunning) {
BackgroundGeolocation1.start(); //triggers start on start event
}
});
BackgroundGeolocation1.on('location', (location) => {
console.log('[ERROR] BackgroundGeolocation ', JSON.stringify(location));
// Alert.alert("Get Location"+ JSON.stringify(location))
});
any update?