diff --git a/integration_test/integration_env.dart b/integration_test/integration_env.dart index a9d8de53..046c9dc2 100644 --- a/integration_test/integration_env.dart +++ b/integration_test/integration_env.dart @@ -16,10 +16,10 @@ import 'package:universal_ble/universal_ble.dart'; /// way the real main() does it — swallow show() instead of throwing. class _NoopLocalNotifications extends FlutterLocalNotificationsPlatform { @override - Future show(int id, String? title, String? body, {String? payload}) async {} + Future show({required int id, String? title, String? body, String? payload}) async {} @override - Future cancel(int id) async {} + Future cancel({required int id}) async {} @override Future cancelAll() async {} diff --git a/lib/bluetooth/connection.dart b/lib/bluetooth/connection.dart index 3d7f64aa..70698fa6 100644 --- a/lib/bluetooth/connection.dart +++ b/lib/bluetooth/connection.dart @@ -1065,10 +1065,11 @@ class Connection { } if (!isSilentReset && !isSilentBackoff) { core.flutterLocalNotificationsPlugin.show( - 1338, - '${device.toString()} ${state ? AppLocalizations.current.connected.decapitalize() : AppLocalizations.current.disconnected.decapitalize()}', - !state ? AppLocalizations.current.tryingToConnectAgain : null, - NotificationDetails( + id: 1338, + title: + '${device.toString()} ${state ? AppLocalizations.current.connected.decapitalize() : AppLocalizations.current.disconnected.decapitalize()}', + body: !state ? AppLocalizations.current.tryingToConnectAgain : null, + notificationDetails: NotificationDetails( android: AndroidNotificationDetails('Connection', 'Connection Status'), iOS: DarwinNotificationDetails(presentAlert: true, presentSound: false), ), @@ -1324,10 +1325,10 @@ class Connection { if (!kIsWeb) { core.flutterLocalNotificationsPlugin.show( - 1339, - AppLocalizations.current.batterySaverTitle, - AppLocalizations.current.controllersDisconnectedInactivity(timeout.inMinutes), - NotificationDetails( + id: 1339, + title: AppLocalizations.current.batterySaverTitle, + body: AppLocalizations.current.controllersDisconnectedInactivity(timeout.inMinutes), + notificationDetails: NotificationDetails( android: AndroidNotificationDetails('BatterySaver', 'Battery Saver'), iOS: DarwinNotificationDetails(presentAlert: true, presentSound: false), ), diff --git a/lib/bluetooth/devices/base_device.dart b/lib/bluetooth/devices/base_device.dart index 8aab5aa7..e2d1a9a5 100644 --- a/lib/bluetooth/devices/base_device.dart +++ b/lib/bluetooth/devices/base_device.dart @@ -655,10 +655,10 @@ abstract class BaseDevice { ), ); core.flutterLocalNotificationsPlugin.show( - 1337, - _getCommandLimitTitle(), - _getCommandLimitMessage(), - NotificationDetails( + id: 1337, + title: _getCommandLimitTitle(), + body: _getCommandLimitMessage(), + notificationDetails: NotificationDetails( android: AndroidNotificationDetails('Limit', 'Limit reached'), iOS: DarwinNotificationDetails(presentAlert: true), ), diff --git a/lib/bluetooth/devices/proxy/proxy_device.dart b/lib/bluetooth/devices/proxy/proxy_device.dart index 8d30be5a..39b5f0e1 100644 --- a/lib/bluetooth/devices/proxy/proxy_device.dart +++ b/lib/bluetooth/devices/proxy/proxy_device.dart @@ -344,10 +344,10 @@ class ProxyDevice extends BluetoothDevice { AlertNotification(LogLevel.LOGLEVEL_WARNING, '$title — $body'), ); core.flutterLocalNotificationsPlugin.show( - 1340, - title, - body, - const NotificationDetails( + id: 1340, + title: title, + body: body, + notificationDetails: const NotificationDetails( android: AndroidNotificationDetails('BridgeTrial', 'Bridge Trial Status'), iOS: DarwinNotificationDetails(presentAlert: true, presentSound: true), ), diff --git a/lib/pages/unlock.dart b/lib/pages/unlock.dart index fe41cb82..4736715c 100644 --- a/lib/pages/unlock.dart +++ b/lib/pages/unlock.dart @@ -240,10 +240,10 @@ class _UnlockPageState extends State with SingleTickerProviderStateM ); core.flutterLocalNotificationsPlugin.show( - 1339, - title, - subtitle, - NotificationDetails( + id: 1339, + title: title, + body: subtitle, + notificationDetails: NotificationDetails( android: AndroidNotificationDetails('Unlocked', 'Device unlocked notification'), iOS: DarwinNotificationDetails(presentAlert: true), ), diff --git a/lib/utils/requirements/android.dart b/lib/utils/requirements/android.dart index a1bcf2b1..a768d68d 100644 --- a/lib/utils/requirements/android.dart +++ b/lib/utils/requirements/android.dart @@ -209,8 +209,12 @@ class NotificationRequirement extends PlatformRequirement { static Future setup() async { print('NOTIFICATION SETUP'); + // macOS has no background-isolate support for notification responses, and + // registering that callback there is the prime suspect for the startup + // hang some macOS users hit — so only wire the background handler off + // macOS. Foreground responses still route through the same handler. await core.flutterLocalNotificationsPlugin.initialize( - InitializationSettings( + settings: InitializationSettings( android: AndroidInitializationSettings( '@drawable/ic_notification', ), @@ -228,7 +232,7 @@ class NotificationRequirement extends PlatformRequirement { guid: '00000012-0000-1000-8000-00805f9b34fb', ), ), - onDidReceiveBackgroundNotificationResponse: notificationTapBackground, + onDidReceiveBackgroundNotificationResponse: Platform.isMacOS ? null : notificationTapBackground, onDidReceiveNotificationResponse: (n) { notificationTapBackground(n); }, @@ -257,9 +261,9 @@ class NotificationRequirement extends PlatformRequirement { ); await AndroidFlutterLocalNotificationsPlugin().startForegroundService( - 1, - channelGroupId, - AppLocalizations.current.allowsRunningInBackground, + id: 1, + title: channelGroupId, + body: AppLocalizations.current.allowsRunningInBackground, foregroundServiceTypes: {AndroidServiceForegroundType.foregroundServiceTypeConnectedDevice}, startType: AndroidServiceStartType.startRedeliverIntent, notificationDetails: AndroidNotificationDetails( diff --git a/lib/utils/settings/settings.dart b/lib/utils/settings/settings.dart index 73bf2c69..a9b5f2f3 100644 --- a/lib/utils/settings/settings.dart +++ b/lib/utils/settings/settings.dart @@ -67,7 +67,10 @@ class Settings { // the support bundle via lastLogEntries, so a report names the culprit we // cannot reproduce. if (!screenshotMode) { - await _guardedInitStep('notifications', () => NotificationRequirement.setup()); + // Fire-and-forget: notification setup has hung on some macOS machines, + // and it's not needed for the app to function — so never let startup + // wait on it at all. The guard still logs if it stalls. + unawaited(_guardedInitStep('notifications', () => NotificationRequirement.setup())); } initializeActions(getLastTarget()?.connectionType ?? ConnectionType.unknown); diff --git a/pubspec.lock b/pubspec.lock index 65cdf7d9..f2da5d06 100755 --- a/pubspec.lock +++ b/pubspec.lock @@ -447,34 +447,42 @@ packages: dependency: "direct main" description: name: flutter_local_notifications - sha256: "19ffb0a8bb7407875555e5e98d7343a633bb73707bae6c6a5f37c90014077875" + sha256: "1447ba911c60f2ba3f25dae1af151ec187162566b0f57e37771bf0b400f013ad" url: "https://pub.dev" source: hosted - version: "19.5.0" + version: "22.3.0" flutter_local_notifications_linux: dependency: transitive description: name: flutter_local_notifications_linux - sha256: e3c277b2daab8e36ac5a6820536668d07e83851aeeb79c446e525a70710770a5 + sha256: "9ca97e63776f29ab1b955725c09999fc2c150523269db150c39274f2a43c5a8b" url: "https://pub.dev" source: hosted - version: "6.0.0" + version: "8.0.1" flutter_local_notifications_platform_interface: dependency: transitive description: name: flutter_local_notifications_platform_interface - sha256: "277d25d960c15674ce78ca97f57d0bae2ee401c844b6ac80fcd972a9c99d09fe" + sha256: "43c3761d916c9bd3d5c7ebbc44d82f4990329840c0c5d62ad5260cc1b5d399bd" url: "https://pub.dev" source: hosted - version: "9.1.0" + version: "12.2.0" + flutter_local_notifications_web: + dependency: transitive + description: + name: flutter_local_notifications_web + sha256: "516afaf97a2d1e67a036c6617321b00d205d72f7a67b6eccf936cd565f985878" + url: "https://pub.dev" + source: hosted + version: "1.0.0" flutter_local_notifications_windows: dependency: transitive description: name: flutter_local_notifications_windows - sha256: "8d658f0d367c48bd420e7cf2d26655e2d1130147bca1eea917e576ca76668aaf" + sha256: "6f43bdd03b171b7a90f22647506fea33e2bb12294b7c7c7a3d690e960a382945" url: "https://pub.dev" source: hosted - version: "1.0.3" + version: "3.1.1" flutter_localizations: dependency: "direct main" description: flutter @@ -1912,10 +1920,10 @@ packages: dependency: transitive description: name: timezone - sha256: dd14a3b83cfd7cb19e7888f1cbc20f258b8d71b54c06f79ac585f14093a287d1 + sha256: "981d1020d6ef8fe1e7b3de5054e5b25579ae7c403d7734adc508ffc47668e9cb" url: "https://pub.dev" source: hosted - version: "0.10.1" + version: "0.11.1" typed_data: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 404c8c57..38425918 100755 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -12,7 +12,7 @@ dependencies: url_launcher: ^6.3.1 android_intent_plus: ^6.0.0 - flutter_local_notifications: ^19.5.0 + flutter_local_notifications: ^22.3.0 # fork to allow iOS background BLE connections universal_ble: diff --git a/test/integration/harness/test_env.dart b/test/integration/harness/test_env.dart index ee22cc28..d0ca6ad4 100644 --- a/test/integration/harness/test_env.dart +++ b/test/integration/harness/test_env.dart @@ -23,10 +23,10 @@ import 'fake_nsd_platform.dart'; /// connection-state notification crashes with a LateInitializationError. class _FakeLocalNotificationsPlatform extends FlutterLocalNotificationsPlatform { @override - Future show(int id, String? title, String? body, {String? payload}) async {} + Future show({required int id, String? title, String? body, String? payload}) async {} @override - Future cancel(int id) async {} + Future cancel({required int id}) async {} @override Future cancelAll() async {}