getInitialNotificationAction method

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

Gets the notification action that launched the app, if any.

This method returns a Future that resolves to a ReceivedAction object if the app was launched by a notification action, or null if it wasn't.

The optional removeFromActionEvents parameter is a boolean value that indicates whether the same action should be prevented from being delivered in the onActionMethod() function, in case it hasn't already happened.

This method does not depend on the setListeners() method being called first, and can be used to retrieve the initial notification action even before the app is fully initialized.

To prevent any delay in application initialization, you can use a timeout with the returned Future to specify a maximum duration for the method to wait for the initial notification action. If no action is received within the timeout duration, the Future will resolve to null. For example:

final initialAction = await getInitialNotificationAction()
    .timeout(Duration(seconds: 5));

Implementation

@override
Future<ReceivedAction?> getInitialNotificationAction(
    {bool removeFromActionEvents = false}) {
  return AwesomeNotificationsPlatform.instance.getInitialNotificationAction(
    removeFromActionEvents: removeFromActionEvents,
  );
}