PushNotificationBloc.fromInitialMessage constructor

PushNotificationBloc.fromInitialMessage(
  1. RemoteMessage? initialMessage
)

Creates a push notification bloc with an initial notification message.

Use this constructor when the app was launched by tapping a notification while it was in a terminated state. The bloc will start in the PushNotificationOpened state if a message is provided.

Parameters:

  • initialMessage: The notification that launched the app, or null

Implementation

PushNotificationBloc.fromInitialMessage(
  RemoteMessage? initialMessage,
) : super(
        initialMessage != null
            ? (initialMessage.notification == null
                ? PushNotificationDataOnlyOpened(
                    payload: initialMessage.payload,
                    linkMobile: initialMessage.linkMobile,
                  )
                : PushNotificationOpened.fromFields(
                    title: initialMessage.title,
                    body: initialMessage.body,
                    payload: initialMessage.payload,
                    linkMobile: initialMessage.linkMobile,
                  ))
            : const PushNotificationInitial(),
      ) {
  _onEvents();
}