Background geolocation not working with targetSdkVersion = 28
Tried to use the app with the example given in the homepage, geolocation did work but whenever app was in background it wasn't working. Debugged it comparing it to the react-native-background-geolocation-example repo, resulted that downgrading targetSdkVersion made it work.
Your Environment
- Plugin version:
- Platform: Android (emulator)
- OS version: Android 9
- Device manufacturer and model: Pixel 2
- Running in Simulator: Android Studio
- React Native version: 0.59.5
- Plugin configuration options:
- Link to your project:
Context
It should work with targetSdkVersion = 28.
Expected Behavior
Background geolocation should still work in the background.
Actual Behavior
Updating the device's location in the background doesn't trigger any updates, even when background geolocation is still "running".
Possible Fix
Steps to Reproduce
- Create a new project & set up background geolocation
- Set up targetSdkVersion = 28 in build.gradle file
- Use the example in the readme and set a console.log or similar in the
BackgroundGeolocation.on('location' ...method - Run the app in background, update the location, the method won't be triggered.
Context
Trying to use the background geolocation basic functionality.
Debug logs
Same issue here
@jl-ib do you found a work around for this issue ?
I have fixed the first issue by adding in the manifest, a new permission for the SDK 28
...
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
...
Ahh this is super helpful, solved the issue for me, thanks a lot @zimski :) how did you find this btw?
Anybody willing to submit a patch?
I am not sure about this fix, seems that working, but I do not have enough time to test it in more detail. Will do it soon.
@jl-ib you welcome !
By inspection the logs, by using adb logcat and read the long java exception.
Hopefully this one was easy to figure out.
Should we close this issue if it is resolved?
Closing, this has been fixed since...