mauron85 / react-native-background-geolocation

Background and foreground geolocation plugin for React Native. Tracks user when app is running in background.
Apache License 2.0
1.33k stars 561 forks source link

Migration to SDK29 seems to be causing background geolocation issues #504

Closed Daavidaviid closed 4 years ago

Daavidaviid commented 4 years ago

Your Environment

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

Daavidaviid commented 4 years ago

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

henriquebk1 commented 4 years ago

Did you request this permission? android.permission.ACCESS_BACKGROUND_LOCATION

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

lyseiha commented 4 years ago

Is it fixed?

Daavidaviid commented 4 years ago

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

lyseiha commented 4 years ago

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

lyseiha commented 4 years ago

Are you using headlessTask as well?

lyseiha commented 4 years ago

Would you mind of sharing snippet of it?

Daavidaviid commented 4 years ago

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,
    });
Daavidaviid commented 4 years ago

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

lyseiha commented 4 years ago

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.

Daavidaviid commented 4 years ago

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

luknoj commented 4 years ago

How did you migrate this to SDK29?

lander854 commented 4 years ago

is this package abandoned?