Skip to content

Commit ebb3ca8

Browse files
committed
windows: always report init failure
Port of MaikuB#2874 commit 149fa4d: the worker calls onReady even if resetting a failed registration throws, so a pending initialize() always completes. Documents retry-or-dispose after a false result.
1 parent fbf6823 commit ebb3ca8

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

‎flutter_local_notifications_windows/lib/src/plugin/ffi.dart‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ class FlutterLocalNotificationsWindows extends WindowsNotificationsBase {
111111
DidReceiveNotificationResponseCallback? userCallback;
112112

113113
/// Calls made while initializing share the first call's settings and result.
114+
/// After a false result, call [initialize] again to retry or [dispose].
114115
@override
115116
Future<bool> initialize({
116117
required WindowsInitializationSettings settings,

‎flutter_local_notifications_windows/src/ffi_api.cpp‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,11 @@ bool init(
4949
} catch (...) {
5050
// Reported as a failure below, so the caller never waits forever.
5151
}
52-
if (!plugin->isReady) plugin->resetRegistration();
52+
try {
53+
if (!plugin->isReady) plugin->resetRegistration();
54+
} catch (...) {
55+
// onReady must still run, or the caller waits forever.
56+
}
5357
onReady(plugin->isReady);
5458
});
5559
}

0 commit comments

Comments
 (0)