Skip to content

ProviderChangeEvent

class ProviderChangeEvent

Location-services provider state delivered to BackgroundGeolocation.onProviderChange.

The SDK fires this event when the user changes location permissions, toggles device location settings, or — on iOS 14 and later — when the precision authorization level changes between full and reduced accuracy.

BackgroundGeolocation.onProviderChange((ProviderChangeEvent event) {
  print('[onProviderChange] enabled: ${event.enabled} status: ${event.status} gps: ${event.gps} network: ${event.network} accuracyAuthorization: ${event.accuracyAuthorization}');

  if (!event.enabled) {
    // Prompt the user to re-enable location services.
  }
});

Members

accuracyAuthorization

int accuracyAuthorization

Precision location authorization level. Use the AccuracyAuthorization constants to interpret this value.

On iOS 14 and later this reflects whether the user has granted full or reduced accuracy. On Android this value is always AccuracyAuthorization.Full.

BackgroundGeolocation.onProviderChange((ProviderChangeEvent event) {
  int authorizationStatus = event.authorizationStatus;
  if (authorizationStatus == ProviderChangeEvent.ACCURACY_AUTHORIZATION_REDUCED) {
    BackgroundGeolocaiton.requestTemporaryFullAccuracy("MyPurposeString").then((int accuracyAuthorization) {
      print("RESULT:  $accuracyAuthorization");
    }).catchError((error) {
      print("ERROR:  Failed to show dialog: $error");
    });
  }
});

enabled

bool enabled

true when the device has at least one location provider enabled.

gps

bool gps

true when the GPS-based location provider is available.

network

bool network

true when the network-based location provider is available.

status

int status

Platform authorization status code. Use the AuthorizationStatus constants to interpret this value.