-
Notifications
You must be signed in to change notification settings - Fork 68
Switching Json Serializer
Elvin (Tharindu) Thudugala edited this page Aug 19, 2022
·
1 revision
Switching Jason Serializer and use Newtonsoft.Json when implementing INotificationSerializer
using Newtonsoft.Json;
public class MyNotificationSerializer : INotificationSerializer
{
public virtual TValue Deserialize<TValue>(string json)
{
return JsonConvert.DeserializeObject<TValue>(json);
}
public virtual string Serialize<TValue>(TValue value)
{
return JsonSerializer.Serialize(value);
}
}
public static class MauiProgram
{
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
....
.UseLocalNotification(config =>
{
config.SetSerializer(new MyNotificationSerializer())
});
return builder.Build();
}
}