onNotificationAction static method
(Android only) Registers a button-click listener on a Custom Notification Layout
ℹ️ See also:
BackgroundGeolocation.ready(Config(
notification: Notification(
actions: [ // <-- register button listeners
"notificationButtonFoo",
"notificationButtonBar"
]
)
));
// Listen to custom button clicks:
BackgroundGeolocation.onNotificationAction((String buttonId) {
print("[onNotificationAction] - ${buttonId}");
switch(buttonId) {
case 'notificationButtonFoo':
break;
case 'notificationButtonBar':
break;
}
});
Implementation
static void onNotificationAction(Function(String) callback) {
if (_eventsNotificationAction == null) {
_eventsNotificationAction = _eventChannelNotificationAction
.receiveBroadcastStream()
.map((dynamic action) => action as String);
}
_registerSubscription(
_eventsNotificationAction!.listen(callback), callback);
}