subscribe static method

Future<void> subscribe({
  1. String? notificationIcon,
  2. Color? backgroundIcon,
})

Implementation

static Future<void> subscribe({
  String? notificationIcon,
  Color? backgroundIcon,
}) async {
  FirebaseMessaging.onBackgroundMessage(_firebaseMessagingBackgroundHandler);
  await requestPermissions();
  await registerFCMToken();

  configureLocalNotifications();

  FirebaseMessaging.onMessage.listen((message) {
    InngageHandlersNotification.handleForegroundNotification(
      remoteMessage: message,
      backgroundColor: backgroundIcon,
    );
  });

  final initialMessage = await FirebaseMessaging.instance.getInitialMessage();
  if (initialMessage != null) {
    InngageHandlersNotification.handleTerminatedNotification(
        remoteMessage: initialMessage,
        onNotificationClick: onNotificationClick);
  }

  FirebaseMessaging.onMessageOpenedApp.listen((message) {
    debugPrint('Mensagem recebida em onMessageOpenedApp: ${message.data}');
    openNotification(message.data);
    onNotificationClick(message.data);
  });
}