react-native-background-geolocation icon indicating copy to clipboard operation
react-native-background-geolocation copied to clipboard

Background geolocation not working with targetSdkVersion = 28

Open jorgeibarra13 opened this issue 7 years ago • 9 comments

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

  1. Create a new project & set up background geolocation
  2. Set up targetSdkVersion = 28 in build.gradle file
  3. Use the example in the readme and set a console.log or similar in the BackgroundGeolocation.on('location' ... method
  4. 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

jorgeibarra13 avatar May 07 '19 21:05 jorgeibarra13

Same issue here

@jl-ib do you found a work around for this issue ?

zimski avatar May 19 '19 15:05 zimski

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" />
...

zimski avatar May 19 '19 15:05 zimski

Ahh this is super helpful, solved the issue for me, thanks a lot @zimski :) how did you find this btw?

jorgeibarra13 avatar May 22 '19 04:05 jorgeibarra13

@zimski you got a Super Like! 😄

Behavior changes: apps targeting API level 28+

djereg avatar May 30 '19 09:05 djereg

Anybody willing to submit a patch?

mauron85 avatar May 30 '19 09:05 mauron85

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.

djereg avatar May 30 '19 10:05 djereg

@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.

zimski avatar Jun 01 '19 00:06 zimski

Should we close this issue if it is resolved?

jacobbeasley avatar Aug 12 '19 13:08 jacobbeasley

Closing, this has been fixed since...

mauron85 avatar Sep 17 '19 18:09 mauron85