React-native-background-geolocation: Migration to SDK29 seems to be causing background geolocation issues

Created on 22 Jul 2020  路  13Comments  路  Source: mauron85/react-native-background-geolocation


Your Environment


  • Plugin version: 0.6.3
  • Platform: Android
  • OS version: Android 10
  • Device manufacturer and model: PixelA3
  • Running in Simulator: YES (And real device too)
  • React Native version: 0.62.2
  • Plugin configuration options:
{
    desiredAccuracy: BackgroundGeolocation.HIGH_ACCURACY,
    fastestInterval: 20 * SECOND,
    interval: 20 * SECOND,
    activitiesInterval: 5000,
    distanceFilter: 50,
    stationaryRadius: 50,
    activityType: 'AutomotiveNavigation',
    startForeground: true,
    postTemplate,
    // @ts-ignore
    syncThreshold: 50,
  }
  • Link to your project:
    Private sources

    Context


I had to migrate from SDK28 to SDK29 on Android, and it looks like since i migrated, the background geolocation isn't working anymore.

Expected Behavior


It should work ok

Actual Behavior


It seems to only be working when the app is in the foreground

Possible Fix


It looks like the foreground service isn't working, I don't know why.

Steps to Reproduce


  1. Create a new React Native App
  2. Added this library
  3. Migrate to SDK29
  4. See the background geolocation fails

Context

Debug logs

Most helpful comment

I think it would be nice if this library was added to https://github.com/react-native-community @react-native-community

All 13 comments

@mauron85 Do you know anything related to this issue ?
I just read about the new changes about foreground services on recent version of android :
https://developer.android.com/preview/privacy/foreground-service-types

Looks like a service might need to be defined with a new property in the AndroidManifest.xml:

<service ...
        android:foregroundServiceType="location" />

What do you think ?

Did you request this permission?
android.permission.ACCESS_BACKGROUND_LOCATION

https://developer.android.com/about/versions/10/privacy/changes

Is it fixed?

Requesting the android.permission.ACCESS_BACKGROUND_LOCATION permission at runtime seems to have fixed it on Android. I'm still having an issue on iOS where the recording stops for a reason I can't understand yet

Did you tried on Chinese custom rom such as Oppo, Vivo ...? i stuck with it for almost 3 weeks already.

Are you using headlessTask as well?

Would you mind of sharing snippet of it?

Did you tried on Chinese custom rom such as Oppo, Vivo ...? i stuck with it for almost 3 weeks already.

Hopefully I didn't have this issue, but it might be link to this : https://dontkillmyapp.com/ what do you think ?

Are you using headlessTask as well?

No only sending the geolocation to the API in the background

Would you mind of sharing snippet of it?

Sure.

BackgroundGeolocation.configure({
      desiredAccuracy: BackgroundGeolocation.HIGH_ACCURACY,
      fastestInterval: 20 * SECOND,
      interval: 20 * SECOND,
      activitiesInterval: 5 * SECOND,
      distanceFilter: 50,
      stationaryRadius: 50,
      notificationTitle: i18n.geolocation.title,
      notificationText: i18n.geolocation.text,
      activityType: 'AutomotiveNavigation',
      startForeground: true,
      httpHeaders,
      pauseLocationUpdates: false,
      locationProvider: BackgroundGeolocation.DISTANCE_FILTER_PROVIDER,
      saveBatteryOnBackground: false,
      debug: false,
      stopOnTerminate: true,
      maxLocations: 100000,
      stopOnStillActivity: false,
      syncUrl: `${baseUrl}/trips/${tripId}/coordinates`,
      url: `${baseUrl}/trips/${tripId}/coordinates`,
      postTemplate,
      // @ts-ignore
      syncThreshold: 10,
    });

I think it would be nice if this library was added to https://github.com/react-native-community @react-native-community

I think it would be nice if this library was added to https://github.com/react-native-community @react-native-community

Support!

Did you tried on Chinese custom rom such as Oppo, Vivo ...? i stuck with it for almost 3 weeks already.

Hopefully I didn't have this issue, but it might be link to this : https://dontkillmyapp.com/ what do you think ?

Are you using headlessTask as well?

No only sending the geolocation to the API in the background

Would you mind of sharing snippet of it?

Sure.

BackgroundGeolocation.configure({
      desiredAccuracy: BackgroundGeolocation.HIGH_ACCURACY,
      fastestInterval: 20 * SECOND,
      interval: 20 * SECOND,
      activitiesInterval: 5 * SECOND,
      distanceFilter: 50,
      stationaryRadius: 50,
      notificationTitle: i18n.geolocation.title,
      notificationText: i18n.geolocation.text,
      activityType: 'AutomotiveNavigation',
      startForeground: true,
      httpHeaders,
      pauseLocationUpdates: false,
      locationProvider: BackgroundGeolocation.DISTANCE_FILTER_PROVIDER,
      saveBatteryOnBackground: false,
      debug: false,
      stopOnTerminate: true,
      maxLocations: 100000,
      stopOnStillActivity: false,
      syncUrl: `${baseUrl}/trips/${tripId}/coordinates`,
      url: `${baseUrl}/trips/${tripId}/coordinates`,
      postTemplate,
      // @ts-ignore
      syncThreshold: 10,
    });

Thank you bro.

I was able to fix my problems on iOS using this library :
https://github.com/transistorsoft/react-native-background-geolocation

It's free on iOS and maintained frequently

How did you migrate this to SDK29?

is this package abandoned?

Was this page helpful?
0 / 5 - 0 ratings