diff --git a/Sample/Direct Maui/LocalNotification.Sample/MainPage.xaml.cs b/Sample/Direct Maui/LocalNotification.Sample/MainPage.xaml.cs index d09452da..8153ed25 100644 --- a/Sample/Direct Maui/LocalNotification.Sample/MainPage.xaml.cs +++ b/Sample/Direct Maui/LocalNotification.Sample/MainPage.xaml.cs @@ -83,7 +83,7 @@ private void ButtonCancel_Clicked(object sender, EventArgs e) private async void Button_Clicked(object sender, EventArgs e) { - var imageStream = GetType().Assembly.GetManifestResourceStream("LocalNotification.Sample.Resources.appicon1.png"); + var imageStream = await FileSystem.OpenAppPackageFileAsync("appicon1.png"); byte[] imageBytes = []; if (imageStream != null) { diff --git a/Sample/Direct Maui/LocalNotification.Sample/Resources/Images/appicon1.png b/Sample/Direct Maui/LocalNotification.Sample/Resources/Raw/appicon1.png similarity index 100% rename from Sample/Direct Maui/LocalNotification.Sample/Resources/Images/appicon1.png rename to Sample/Direct Maui/LocalNotification.Sample/Resources/Raw/appicon1.png diff --git a/Source/Plugin.LocalNotification/Json/NotificationSerializer.cs b/Source/Plugin.LocalNotification/Json/NotificationSerializer.cs index defa8026..ae8c8151 100644 --- a/Source/Plugin.LocalNotification/Json/NotificationSerializer.cs +++ b/Source/Plugin.LocalNotification/Json/NotificationSerializer.cs @@ -1,20 +1,26 @@ using System.Text.Json; +using System.Text.Json.Serialization; namespace Plugin.LocalNotification.Json { /// internal class NotificationSerializer : INotificationSerializer { + private readonly JsonSerializerOptions _options = new() + { + NumberHandling = JsonNumberHandling.AllowNamedFloatingPointLiterals + }; + /// public virtual TValue? Deserialize(string json) { - return JsonSerializer.Deserialize(json); + return JsonSerializer.Deserialize(json, _options); } /// public virtual string Serialize(TValue value) { - return JsonSerializer.Serialize(value); + return JsonSerializer.Serialize(value, _options); } } } \ No newline at end of file diff --git a/Source/Plugin.LocalNotification/LocalNotificationExtensions.cs b/Source/Plugin.LocalNotification/LocalNotificationExtensions.cs index b7047119..cc6585b0 100644 --- a/Source/Plugin.LocalNotification/LocalNotificationExtensions.cs +++ b/Source/Plugin.LocalNotification/LocalNotificationExtensions.cs @@ -29,11 +29,11 @@ public static MauiAppBuilder UseLocalNotification(this MauiAppBuilder builder, A life.AddAndroid(android => { android.OnCreate((activity, _) => - { - LocalNotificationCenter.CreateNotificationChannels(localNotificationBuilder.AndroidBuilder.ChannelRequestList); - + { LocalNotificationCenter.CreateNotificationChannelGroups(localNotificationBuilder.AndroidBuilder.GroupChannelRequestList); + LocalNotificationCenter.CreateNotificationChannels(localNotificationBuilder.AndroidBuilder.ChannelRequestList); + LocalNotificationCenter.NotifyNotificationTapped(activity.Intent); }) .OnNewIntent((_, intent) => diff --git a/Source/Plugin.LocalNotification/NotificationRequestGeofence.cs b/Source/Plugin.LocalNotification/NotificationRequestGeofence.cs index 4ae3c93e..53e690b9 100644 --- a/Source/Plugin.LocalNotification/NotificationRequestGeofence.cs +++ b/Source/Plugin.LocalNotification/NotificationRequestGeofence.cs @@ -37,7 +37,7 @@ public class NotificationRequestGeofence /// /// /// - public bool IsGeofence => Center != null; + public bool IsGeofence => Center != null && Center.IsPositionSet; /// /// @@ -47,12 +47,14 @@ public class Position /// /// Latitude in degrees, between -90 and +90 inclusive /// - public double Latitude { get; set; } + public double Latitude { get; set; } = double.NaN; /// /// Longitude in degrees, between -180 and +180 inclusive. /// - public double Longitude { get; set; } + public double Longitude { get; set; } = double.NaN; + + public bool IsPositionSet => !double.IsNaN(Latitude) && !double.IsNaN(Longitude); } /// diff --git a/Source/Plugin.LocalNotification/Platforms/Android/LocalNotificationCenter.cs b/Source/Plugin.LocalNotification/Platforms/Android/LocalNotificationCenter.cs index f4b5ff6d..1fecbbbf 100644 --- a/Source/Plugin.LocalNotification/Platforms/Android/LocalNotificationCenter.cs +++ b/Source/Plugin.LocalNotification/Platforms/Android/LocalNotificationCenter.cs @@ -104,7 +104,7 @@ internal static void CreateNotificationChannels(IList