From ca9cf687eafa1921eba34f4bf2878a6beb9db7ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elias=20M=C3=BCller?= <elias@elias-mueller.com> Date: Sun, 20 Aug 2023 19:06:35 +0200 Subject: [PATCH] Fixed notification bug regarding to iOS --- lib/notification/notificationController.dart | 5 +++-- lib/notification/notificationService.dart | 15 ++++++++++----- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/lib/notification/notificationController.dart b/lib/notification/notificationController.dart index 22a6b13..892f659 100644 --- a/lib/notification/notificationController.dart +++ b/lib/notification/notificationController.dart @@ -30,8 +30,9 @@ class NotificationController { final NotificationService service = NotificationService(); service.initializeNotifications().then((value) { service.showNotification( - title: "Du hast $messageCount ungelesene Nachrichten!", - body: "In $chatCount Chats, von ${people.join(", ")}" + title: "Du hast $messageCount ungelesene Nachrichten!", + body: "In $chatCount Chats, von ${people.join(", ")}", + badgeCount: messageCount, ); }); }); diff --git a/lib/notification/notificationService.dart b/lib/notification/notificationService.dart index 77fdc8c..ab43f17 100644 --- a/lib/notification/notificationService.dart +++ b/lib/notification/notificationService.dart @@ -39,17 +39,22 @@ class NotificationService { ); } - Future<void> showNotification({required String title, required String body}) async { + Future<void> showNotification({required String title, required String body, required int badgeCount}) async { const AndroidNotificationDetails androidPlatformChannelSpecifics = AndroidNotificationDetails( - 'your_channel_id', - 'Your Channel Name', + 'marmobile', + 'Marianum Fulda', importance: Importance.defaultImportance, priority: Priority.defaultPriority, - ticker: 'ticker', + ticker: 'Marianum Fulda', ); - const NotificationDetails platformChannelSpecifics = NotificationDetails(android: androidPlatformChannelSpecifics); + const DarwinNotificationDetails iosPlatformChannelSpecifics = DarwinNotificationDetails(); + + const NotificationDetails platformChannelSpecifics = NotificationDetails( + android: androidPlatformChannelSpecifics, + iOS: iosPlatformChannelSpecifics + ); await flutterLocalNotificationsPlugin.show( 0,