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