React-native-background-geolocation: Background geolocation not working with targetSdkVersion = 28

Created on 7 May 2019  路  9Comments  路  Source: mauron85/react-native-background-geolocation



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

good first issue

Most helpful comment

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

All 9 comments

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?

@zimski you got a Super Like! 馃槃

Behavior changes: apps targeting API level 28+

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MRolandd picture MRolandd  路  6Comments

sefatunckanat picture sefatunckanat  路  7Comments

mikailbayram picture mikailbayram  路  4Comments

HaswinVidanage picture HaswinVidanage  路  3Comments

ianaz picture ianaz  路  4Comments