subscribe static method
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);
});
}