onGeofence static method

void onGeofence(
  1. dynamic callback(
    1. GeofenceEvent
    )
)

Subscribe to Geofence transition events.

Your supplied callback will be called when any monitored geofence crossing occurs.

Example

BackgroundGeolocation.onGeofence((GeofenceEvent event) { print('onGeofence ${event}'); });

Implementation

static void onGeofence(Function(GeofenceEvent) callback) {
  if (_eventsGeofence == null) {
    _eventsGeofence = _eventChannelGeofence
        .receiveBroadcastStream()
        .map((dynamic event) => GeofenceEvent(event));
  }
  _registerSubscription(_eventsGeofence!.listen(callback), callback);
}