INNER CODE UNIT · Dart
onNotificationAction
transistorsoft/flutter_background_geolocation · lib/models/background_geolocation.dart:1754
static Subscription onNotificationAction(Function(String) callback) {
if (_eventsNotificationAction == null) {
_eventsNotificationAction = _eventChannelNotificationAction
.receiveBroadcastStream()
.map((dynamic action) => action as String);
}
_registerSubscription(
_eventsNotificationAction!.listen(callback), callback);
return Subscription._(() async {
removeListener(callback);
});
}
/// Registers a function to receive events from __`BackgroundGeolocation`__ while in the *terminated* ("Headless") state.
///
/// __Note:__ Requires [AppConfig.enableHeadless]:true. See the [Android Headless Mode Guide](https://github.com/transistorsoft/flutter_background_geolocation/wiki/Android-Headless-Mode).
///
/// In **`main.dart`**, create a global function beside `void main() {}` (**Must** be defined as a distinct function, not an anonymous callback), annotated with `@pragma('vm:entry-point')` — without it, release builds can strip the function. This `function` will receive *all* events from `BackgroundGeolocation` in the headless state, and provided with a [HeadlessEvent] containing a [HeadlessEvent.name] and [HeadlessEvent.event].