getInitialNotificationAction method

  1. @override
Future<ReceivedAction?> getInitialNotificationAction({
  1. bool removeFromActionEvents = false,
})
override

Gets the notification action that launched the app. If the app wasn't launched by a notification, so it returns null. This method does not depend on setListeners being called first. removeFromActionEvents when set to true, prevents the same action from being delivered in the method onActionMethod, in case it hasn't already happened

Implementation

@override
Future<ReceivedAction?> getInitialNotificationAction(
    {bool removeFromActionEvents = false}) async {
  dynamic returnedData = await methodChannel.invokeMethod(
      CHANNEL_METHOD_GET_INITIAL_ACTION, removeFromActionEvents);
  if (returnedData == null) return null;

  Map<String, dynamic>? actionData = Map<String, dynamic>.from(returnedData);
  ReceivedAction? receivedAction = ReceivedAction().fromMap(actionData);
  return receivedAction;
}