onDidReceiveNotificationResponse function

void onDidReceiveNotificationResponse(
  1. NotificationResponse response
)

Handles a tap on a notification shown by FlutterLocalNotificationManager.

If the payload is the id of a UserTask, calls AppTaskController.onNotification. Otherwise the payload is emitted on FlutterLocalNotificationManager.notificationTaps. Top-level and marked as an entry point, so it can also run when the app is in the background.

Implementation

@pragma('vm:entry-point')
void onDidReceiveNotificationResponse(NotificationResponse response) {
  String? payload = response.payload;
  debug('NotificationManager - callback on notification, payload: $payload');

  if (payload == null) {
    warning("NotificationManager - Error in callback from notification - payload is '$payload'");
  } else if (AppTaskController().getUserTask(payload) != null) {
    AppTaskController().onNotification(payload);
  } else {
    FlutterLocalNotificationManager()._taps.add(payload);
  }
}