onAuthorization static method

void onAuthorization(
  1. dynamic callback(
    1. AuthorizationEvent
    )
)

Listen to Authorization events from Authorization.refreshUrl.

If you've configured Config.authorization, this event will be fired when your Authorization.refreshUrl returns a response, either successfully or not.

BackgroundGeolocation.onAuthorization((Authorization event) {
  print("[authorization] $event");

  if (event.success) {
    print("- Authorization response: ${event.response}");
  } else {
    print("- Authorization error: ${event.message}");
  }
});

Implementation

static void onAuthorization(Function(AuthorizationEvent) callback) {
  if (_eventsAuthorization == null) {
    _eventsAuthorization = _eventChannelAuthorization
        .receiveBroadcastStream()
        .map((dynamic event) => AuthorizationEvent(event));
  }
  _registerSubscription(_eventsAuthorization!.listen(callback), callback);
}