Skip to content

Commit

Permalink
converting to .net 8
Browse files Browse the repository at this point in the history
  • Loading branch information
thudugala committed Nov 19, 2023
1 parent 1a5513d commit 9877708
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
10 changes: 8 additions & 2 deletions Source/Plugin.LocalNotification/Json/NotificationSerializer.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
using System.Text.Json;
using System.Text.Json.Serialization;

namespace Plugin.LocalNotification.Json
{
/// <inheritdoc />
internal class NotificationSerializer : INotificationSerializer
{
private readonly JsonSerializerOptions _options = new()
{
NumberHandling = JsonNumberHandling.AllowNamedFloatingPointLiterals
};

/// <inheritdoc />
public virtual TValue? Deserialize<TValue>(string json)
{
return JsonSerializer.Deserialize<TValue>(json);
return JsonSerializer.Deserialize<TValue>(json, _options);
}

/// <inheritdoc />
public virtual string Serialize<TValue>(TValue value)
{
return JsonSerializer.Serialize(value);
return JsonSerializer.Serialize(value, _options);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class NotificationRequestGeofence
/// <summary>
///
/// </summary>
public bool IsGeofence => Center != null;
public bool IsGeofence => Center != null && Center.IsPositionSet;

/// <summary>
///
Expand All @@ -47,12 +47,14 @@ public class Position
/// <summary>
/// Latitude in degrees, between -90 and +90 inclusive
/// </summary>
public double Latitude { get; set; }
public double Latitude { get; set; } = double.NaN;

/// <summary>
/// Longitude in degrees, between -180 and +180 inclusive.
/// </summary>
public double Longitude { get; set; }
public double Longitude { get; set; } = double.NaN;

public bool IsPositionSet => !double.IsNaN(Latitude) && !double.IsNaN(Longitude);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ internal static void CreateNotificationChannels(IList<NotificationChannelRequest
var channel = new NotificationChannel(channelRequest.Id, channelRequest.Name, channelRequest.Importance.ToNative())
{
Description = channelRequest.Description,
Group = channelRequest.Group,
Group = string.IsNullOrWhiteSpace(channelRequest.Group) ? null : channelRequest.Group,
LightColor = channelRequest.LightColor.ToNative(),
LockscreenVisibility = channelRequest.LockScreenVisibility.ToNative(),
};
Expand Down

0 comments on commit 9877708

Please sign in to comment.