react-native-background-geolocation
react-native-background-geolocation copied to clipboard
RNBackgroundGeolocation is not working in background mode android above OS 11 versions
Your Environment
- Plugin version: 4.10.1
- Platform: Android
- OS version: Above 11
- Device manufacturer / model: All devices
- React Native version (
react-native -v):0.70.6 - Plugin config
BackgroundGeolocation.onGeofence(geofence => {
console.log("[geofence] ", geofence);
if (geofence.identifier == "DANGER_ZONE") {
if (geofence.action == "ENTER") {
// Entering the danger-zone, we want to aggressively track location.
BackgroundGeolocation.start();
console.log('enter the region');
} else if (geofence.action == "EXIT") {
// Exiting the danger-zone, we resume geofences-only tracking.
BackgroundGeolocation.startGeofences();
}
}
})
// Add a geofence.
BackgroundGeolocation.addGeofence({
identifier: "DANGER_ZONE",
radius: 200,
latitude: this.state.destinationLatitude,
longitude: this.state.destinationLongitude,
notifyOnEntry: true,
notifyOnExit: true,
})
// Ready the plugin.
BackgroundGeolocation.ready({
desiredAccuracy: BackgroundGeolocation.DESIRED_ACCURACY_HIGH,
distanceFilter: 10,
// url: "http://your.server.com/locations",
geofenceModeHighAccuracy: true,
autoSync: true
}, state => {
BackgroundGeolocation.startGeofences();
})
Expected Behavior
How it is working in foreground when we reach destination in same way in background mode as well
Actual Behavior
Working only in foreground mode only in android
Steps to Reproduce
1.run the application 2.and moving the app into background mode checking console in emulator as well as real device 3. no logs updated as per background mode 4.
Context
updated the config object and some changes in build.gradle file
Debug logs

Do no post screenshots of logs. Post actual text
As for the error you see about FLAG_MUTABLE or FLAG_IMMUTABLE, the plugin has supported these flags for the last two years.
Plugin version: 4.10.1
I think you are lying about the version you're actually using. I think you're using a much older version.
I primarily develop on Android 13 devices with targetSdkVersion 33, compileSdkVersion 33. The problem is on your end, not with the plugin.


Let me know how to reproduce this error in a simple Hello World app.
Now its throwing "BackgroundGeolocation is disabled" this issue whenever we call ready function
Because you’re implementing the code incorrectly and probably trying to call .changePace(true) before .ready has resolved.
how can we call change pace everytime or after ready state enabled coming false many times. is there any solution? Did you tried the above scenario to overcome the above issue
Did you tried the above scenario to overcome the above issue
I don’t have to “try” it. You are clearly trying to tell the plug-in to .changePace(true) while State.enabled == false.
It’s like trying to push the accelerator pedal in car while the engine is off.
// turn on the engine
await BackgroundGeolocation.start()
// hit the gas
await BackgroundGeolocation.changePace(true)
This issue is stale because it has been open for 30 days with no activity.
This issue was closed because it has been inactive for 14 days since being marked as stale.