Implementation
Future<void> firebaseMessagingForegroundHandler(RemoteMessage message) {
LogManager().addLog("firebaseMessagingForegroundHandler: ${message.data}", screen: runtimeType.toString());
math.Random rng = math.Random();
// (안드로이드만 해당) 여러 알림이 왔을때 알림을 구별하기위해 랜덤 숫자를 생성함
int tag = rng.nextInt(9999999);
Map<String, dynamic> pinpointMessage = message.data;
pinpointMessage["pinpoint.notification.title"] = message.notification!.title!;
pinpointMessage["pinpoint.notification.body"] = message.notification!.body!;
if (pinpointMessage["pinpoint.notification.imageUrl"] != null && pinpointMessage["pinpoint.notification.imageIconUrl"] != null) {
log("h2");
return showBigPictureNotification(pinpointMessage);
} else if (pinpointMessage["pinpoint.notification.imageUrl"] != null) {
return showBigPictureNotificationHiddenLargeIcon(pinpointMessage);
} else {
return flutterLocalNotificationsPlugin.show(
tag,
pinpointMessage["pinpoint.notification.title"],
pinpointMessage["pinpoint.notification.body"],
NotificationDetails(
android: AndroidNotificationDetails(
'high_importance_channel', // id
'High Importance Notifications', // title
channelDescription: 'This channel is used for important notifications.',
// description
importance: Importance.high,
icon: null,
tag: tag.toString(),
),
),
);
}
}