mirror of
https://github.com/jonasbark/swiftcontrol.git
synced 2026-11-28 16:58:41 +01:00
fix(notifications): bump flutter_local_notifications 19→22.3.0 + stop the macOS startup hang
The macOS "won't start" freeze was flutterLocalNotificationsPlugin.initialize() hanging in NotificationRequirement.setup() — confirmed by an affected user's log (Startup step "notifications" timed out after 6s) on the x86_64/Rosetta slice. - Make notification setup fire-and-forget in settings.init() so startup never waits on it (it's non-essential; the guard still logs if it stalls). - Drop onDidReceiveBackgroundNotificationResponse on macOS — macOS has no background-isolate support for it and registering it is the prime suspect for the hang. - Bump flutter_local_notifications ^19.5.0 → ^22.3.0 and migrate for the v20 named-parameter change: initialize(settings:), show(id:/title:/body:/ notificationDetails:), startForegroundService(id:/title:/body:) across android/connection/base_device/proxy/unlock, plus the two test fakes' show()/cancel() overrides. Flutter 3.47 compileSdk=36 satisfies fln 22's floor. Verified: flutter analyze clean, macOS debug build, integration + notification tests pass. Android foreground-service / action-button behaviour needs on-device or CI verification.
This commit is contained in:
@@ -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<void> show(int id, String? title, String? body, {String? payload}) async {}
|
||||
Future<void> show({required int id, String? title, String? body, String? payload}) async {}
|
||||
|
||||
@override
|
||||
Future<void> cancel(int id) async {}
|
||||
Future<void> cancel({required int id}) async {}
|
||||
|
||||
@override
|
||||
Future<void> cancelAll() async {}
|
||||
|
||||
@@ -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),
|
||||
),
|
||||
|
||||
@@ -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),
|
||||
),
|
||||
|
||||
@@ -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),
|
||||
),
|
||||
|
||||
@@ -240,10 +240,10 @@ class _UnlockPageState extends State<UnlockPage> 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),
|
||||
),
|
||||
|
||||
@@ -209,8 +209,12 @@ class NotificationRequirement extends PlatformRequirement {
|
||||
|
||||
static Future<void> 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(
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
28
pubspec.lock
28
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:
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -23,10 +23,10 @@ import 'fake_nsd_platform.dart';
|
||||
/// connection-state notification crashes with a LateInitializationError.
|
||||
class _FakeLocalNotificationsPlatform extends FlutterLocalNotificationsPlatform {
|
||||
@override
|
||||
Future<void> show(int id, String? title, String? body, {String? payload}) async {}
|
||||
Future<void> show({required int id, String? title, String? body, String? payload}) async {}
|
||||
|
||||
@override
|
||||
Future<void> cancel(int id) async {}
|
||||
Future<void> cancel({required int id}) async {}
|
||||
|
||||
@override
|
||||
Future<void> cancelAll() async {}
|
||||
|
||||
Reference in New Issue
Block a user