react-native-background-geolocation: LocationAuthorizationAlert spawning continuously, blocks app usage

Sometimes, when our app does not have permission to access Location Services, it gets into a state where the locationAuthorizationAlert pops up continuously, completely blocking usage of the app. Going into Settings and granting the app the correct permissions has no effect, it just keeps creating more alerts. Swiping away and restarting the app is the only solution.

We have not narrowed down exactly the conditions required to reproduce this, but it seems to happen when the app is running in the background for long periods of time (e.g. overnight) without the right permissions. Any ideas for what could be causing this? Is there some way to just disable those alerts for now?

Your Environment

  • Plugin version: 1.6.0 from NativeEventEmitter branch (commit 3a9d650798307dc6b227c96e0c1cc49be8e58214)
  • Platform: iOS
  • OS version: 10.0.1
  • Device manufacturer / model: iPad Air 2
  • React Native version (react-native -v): 0.39.1
  • Plugin config
      // Geolocation Config
      license: 'our-license',
      desiredAccuracy: 0,
      stationaryRadius: 25,
      distanceFilter: 10,
      // Activity Recognition
      stopTimeout: 60,
      stopDetectionDelay: 60,
      locationUpdateInterval: 1000,
      // Application config
      stopOnTerminate: true,
      startOnBoot: false,
      maxRecordsToPersist: 1,
      url: queuePostURL,
      autoSync: false,

Expected Behavior

When the app doesn’t have the correct permissions, it should pop up the locationAuthorizationAlert once.

Actual Behavior

The alert pops up, but pressing Cancel spawns a new one. Pressing Settings opens up the Settings app correctly, but then another alert is spawned as soon as we switch back to our app. This repeats until we restart the app.

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 1
  • Comments: 19 (11 by maintainers)

Most upvoted comments

I’ve fixed the docs in master, adding the missing locationAuthorizationAlert, locationAuthorizationRequest.

https://github.com/transistorsoft/react-native-background-geolocation/tree/master/docs#param-object-locationauthorizationalert

I posted the fix the the Premium Version only so far (the referenced branch exists there), where I’m waiting for feedback. Latest updates are only available in the premium version.

It used to be that the premium version contained only the Android version, but I’ve since merged iOS there now as well.

As for disabling the alert, no. If you don’t want the alert to appear, don’t ask the plugin to fetch a location. Listen to the providerchange event, for example:

bgGeo.on('providerchange', function(provider) {
  if (provider.enabled) {
    bgGeo.start();
  } else {
    bgGeo.stop();  // <-- When location-services are disabled, turn off the plugin.
  }
});

The free version here contain only the latest stable release.

I was not aware of the missing locationAuthorizationAlert. That’s a bug. If you need those docs now, you can reference them in the Cordova Version (the docs are identical).

I think I’ve got a solution for this from the Cordova side. I’m just waiting for feedback. I’ll post a new version of TSLocationManager.framework here once it’s confirmed.