admin管理员组文章数量:1353272
I working with the Plugin.LocalNotification nuget package to get notifications in the app. I need to schedule the notification to a specified date, like 2025.04.15 12:00:00, i want to notify the user one hour before the date, but the plugin does not work, if I set the notfy time 15 minutes from tapping on the button, it does not show the notification, but if it's 5 minutes it's shows it. Can sombody reccommend some solution for this, or another approach to send notifications.
AnroidManifest.xml:
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.USE_EXACT_ALARM" />
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
Function:
private async Task ScheduleNotification(FavouritePartyListModel partyListModel)
{
var notificationAllowed = await LocalNotificationCenter.Current.AreNotificationsEnabled();
if (!notificationAllowed)
{
var requestResult = await LocalNotificationCenter.Current.RequestNotificationPermission();
if (!requestResult)
return;
}
var request = new NotificationRequest
{
NotificationId = (int)partyListModel.Party.Id,
Title = partyListModel.Party.Name,
Description = "1 óra múlva kezdődik az esemény!",
Schedule = new NotificationRequestSchedule
{
NotifyTime = partyListModel.Party.StartDate.AddHours(-1)
},
};
var favouritePartyModel = new FavouritePartyModel
{
PartyId = (int)partyListModel.Party.Id,
UserId = userId,
IsNotificationOn = true
};
var result = await favouritePartyService.UpdateFavouritePartyNotification(favouritePartyModel);
if (result.IsError)
return;
await LocalNotificationCenter.Current.Show(request);
partyListModel.IsNotificationOn = true;
}
本文标签: cMaui Local notification does not work when the Schedule is more than 5 minutesStack Overflow
版权声明:本文标题:c# - Maui Local notification does not work when the Schedule is more than 5 minutes - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743922399a2562334.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论