I try to add LocalNotification to the application, everything works in Debug mode, but when I change to Release mode, notifications do not work. Anyone know how to deal with it?
using Plugin.LocalNotification;
namespace TestNotif;
public static class MauiProgram
{
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
.UseLocalNotification()
.ConfigureFonts(fonts =>
{
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
});
return builder.Build();
}
}
I got this error CS1061:
Severity Code Description Project File Line Suppression State Error CS1061 'MauiAppBuilder' does not contain a definition for 'UseLocalNotification' and no accessible extension method 'UseLocalNotification' accepting a first argument of type 'MauiAppBuilder' could be found (are you missing a using directive or an assembly reference?) TestNotif (net6.0-maccatalyst), TestNotif (net6.0-windows10.0.19041.0) C:\Users---\source\repos\TestNotif\TestNotif\MauiProgram.cs 14 Active
using Plugin.LocalNotification;
using System;
namespace TestNotif;
public partial class MainPage : ContentPage
{
int count = 0;
public MainPage()
{
InitializeComponent();
NotificationGet();
}
public async void Button_Clicked(object sender, EventArgs e)
{
var notification6 = new NotificationRequest
{
BadgeNumber = 1,
Description = "Test Description",
Title = "Notification!",
ReturningData = "Dummy Data",
NotificationId = 1327,
Schedule =
{
NotifyTime = DateTime.Now.AddSeconds(5)
}
};
await LocalNotificationCenter.Current.Show(notification6);
}