diff --git a/Source/Plugin.LocalNotification/Platforms/MacCatalyst/LocalNotificationCenter.cs b/Source/Plugin.LocalNotification/Platforms/MacCatalyst/LocalNotificationCenter.cs index 5d97c40..4a20edf 100644 --- a/Source/Plugin.LocalNotification/Platforms/MacCatalyst/LocalNotificationCenter.cs +++ b/Source/Plugin.LocalNotification/Platforms/MacCatalyst/LocalNotificationCenter.cs @@ -61,10 +61,14 @@ public static void ResetApplicationIconBadgeNumber(UIApplication uiApplication) var completionSource = new TaskCompletionSource(); UNUserNotificationCenter.Current.GetDeliveredNotifications((notificationArray) => { - notificationList.AddRange(notificationArray); + if (notificationArray != null) + { + notificationList.AddRange(notificationArray); + } completionSource.SetResult(true); }); completionSource.Task.Wait(); + if (notificationList.Count != 0) { return; diff --git a/Source/Plugin.LocalNotification/Platforms/iOS/LocalNotificationCenter.cs b/Source/Plugin.LocalNotification/Platforms/iOS/LocalNotificationCenter.cs index 12bcbd2..02dc538 100644 --- a/Source/Plugin.LocalNotification/Platforms/iOS/LocalNotificationCenter.cs +++ b/Source/Plugin.LocalNotification/Platforms/iOS/LocalNotificationCenter.cs @@ -61,10 +61,14 @@ public static void ResetApplicationIconBadgeNumber(UIApplication uiApplication) var completionSource = new TaskCompletionSource(); UNUserNotificationCenter.Current.GetDeliveredNotifications((notificationArray) => { - notificationList.AddRange(notificationArray); + if (notificationArray != null) + { + notificationList.AddRange(notificationArray); + } completionSource.SetResult(true); }); completionSource.Task.Wait(); + if (notificationList.Count != 0) { return;