From 93954d434a2b93958e7ab1d09ad282a60b618adc Mon Sep 17 00:00:00 2001 From: Christian Pauly Date: Mon, 17 Oct 2022 17:48:38 +0200 Subject: [PATCH] chore: Update local notifications package --- lib/pages/chat_list/chat_list.dart | 10 ++++------ lib/utils/background_push.dart | 5 +++-- lib/utils/push_helper.dart | 18 ++++++++++-------- lib/widgets/matrix.dart | 2 +- pubspec.lock | 8 ++++---- pubspec.yaml | 2 +- 6 files changed, 23 insertions(+), 22 deletions(-) diff --git a/lib/pages/chat_list/chat_list.dart b/lib/pages/chat_list/chat_list.dart index 61d7cbab..35e23552 100644 --- a/lib/pages/chat_list/chat_list.dart +++ b/lib/pages/chat_list/chat_list.dart @@ -553,12 +553,10 @@ class ChatListController extends State } } } - if (mounted) { - setState(() { - waitForFirstSync = true; - }); - } - return; + if (!mounted) return; + setState(() { + waitForFirstSync = true; + }); } void cancelAction() { diff --git a/lib/utils/background_push.dart b/lib/utils/background_push.dart index 8bf3f37d..14100768 100644 --- a/lib/utils/background_push.dart +++ b/lib/utils/background_push.dart @@ -250,7 +250,7 @@ class BackgroundPush { return; } _wentToRoomOnStartup = true; - goToRoom(details.payload); + goToRoom(details.notificationResponse); }); } @@ -294,8 +294,9 @@ class BackgroundPush { ); } - Future goToRoom(String? roomId) async { + Future goToRoom(NotificationResponse? response) async { try { + final roomId = response?.payload; Logs().v('[Push] Attempting to go to room $roomId...'); if (router == null || roomId == null) { return; diff --git a/lib/utils/push_helper.dart b/lib/utils/push_helper.dart index 9384f0d7..3409bb24 100644 --- a/lib/utils/push_helper.dart +++ b/lib/utils/push_helper.dart @@ -20,7 +20,7 @@ Future pushHelper( Client? client, L10n? l10n, String? activeRoomId, - Future Function(String?)? onSelectNotification, + void Function(NotificationResponse?)? onSelectNotification, }) async { try { await _tryPushHelper( @@ -38,16 +38,17 @@ Future pushHelper( await flutterLocalNotificationsPlugin.initialize( const InitializationSettings( android: AndroidInitializationSettings('notifications_icon'), - iOS: IOSInitializationSettings(), + iOS: DarwinInitializationSettings(), ), - onSelectNotification: onSelectNotification, + onDidReceiveNotificationResponse: onSelectNotification, + onDidReceiveBackgroundNotificationResponse: onSelectNotification, ); flutterLocalNotificationsPlugin.show( 0, l10n?.newMessageInFluffyChat, l10n?.openAppToReadMessages, NotificationDetails( - iOS: const IOSNotificationDetails(), + iOS: const DarwinNotificationDetails(), android: AndroidNotificationDetails( AppConfig.pushNotificationsChannelId, AppConfig.pushNotificationsChannelName, @@ -67,7 +68,7 @@ Future _tryPushHelper( Client? client, L10n? l10n, String? activeRoomId, - Future Function(String?)? onSelectNotification, + void Function(NotificationResponse?)? onSelectNotification, }) async { final isBackgroundMessage = client == null; Logs().v( @@ -88,9 +89,10 @@ Future _tryPushHelper( await flutterLocalNotificationsPlugin.initialize( const InitializationSettings( android: AndroidInitializationSettings('notifications_icon'), - iOS: IOSInitializationSettings(), + iOS: DarwinInitializationSettings(), ), - onSelectNotification: onSelectNotification, + onDidReceiveNotificationResponse: onSelectNotification, + //onDidReceiveBackgroundNotificationResponse: onSelectNotification, ); client ??= (await ClientManager.getClients(initialize: false)).first; @@ -206,7 +208,7 @@ Future _tryPushHelper( priority: Priority.high, groupKey: event.room.id, ); - const iOSPlatformChannelSpecifics = IOSNotificationDetails(); + const iOSPlatformChannelSpecifics = DarwinNotificationDetails(); final platformChannelSpecifics = NotificationDetails( android: androidPlatformChannelSpecifics, iOS: iOSPlatformChannelSpecifics, diff --git a/lib/widgets/matrix.dart b/lib/widgets/matrix.dart index bb4ddbde..fa8d9fd4 100644 --- a/lib/widgets/matrix.dart +++ b/lib/widgets/matrix.dart @@ -409,7 +409,7 @@ class MatrixState extends State with WidgetsBindingObserver { action: link == null ? null : SnackBarAction( - label: L10n.of(context)!.link, + label: L10n.of(navigatorContext)!.link, onPressed: () => launch(link.toString()), ), ); diff --git a/pubspec.lock b/pubspec.lock index 6c866c91..8b2ad768 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -584,21 +584,21 @@ packages: name: flutter_local_notifications url: "https://pub.dartlang.org" source: hosted - version: "9.7.0" + version: "12.0.2" flutter_local_notifications_linux: dependency: transitive description: name: flutter_local_notifications_linux url: "https://pub.dartlang.org" source: hosted - version: "0.5.0+1" + version: "1.0.0" flutter_local_notifications_platform_interface: dependency: transitive description: name: flutter_local_notifications_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "5.0.0" + version: "6.0.0" flutter_localizations: dependency: "direct main" description: flutter @@ -1682,7 +1682,7 @@ packages: name: timezone url: "https://pub.dartlang.org" source: hosted - version: "0.8.0" + version: "0.9.0" tint: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index faca9898..6f0c5430 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -37,7 +37,7 @@ dependencies: flutter_blurhash: ^0.7.0 flutter_cache_manager: ^3.3.0 flutter_foreground_task: ^3.10.0 - flutter_local_notifications: ^9.7.0 + flutter_local_notifications: ^12.0.2 flutter_localizations: sdk: flutter flutter_map: ^2.2.0