thudugala / thudugala/Plugin.LocalNotification

Users can't enable the reminder for the app

Open
#503 4 comments 0 reactions 1 assignee View on GitHub

@thudugala is already working on this.

Since May 31, 2024.

Android bug
Dominant language
C#
Stars
474
Forks
73
PR merge metrics
No merged PRs in 30d

Description

In my NET8 MAUI apps, I want to send a local notification every day to remind the user to use the app. For that, I'm using the component Plugin.LocalNotification. For Android, in the AndroidManifest.xml, I added those lines

<uses-permission android:name="android.permission.WAKE_LOCK" />

<!--Required so that the plugin can reschedule notifications upon a reboot-->
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />

Then I created a service to manage the notification and checked if the user gave the consent to use the app.

INotificationService _notificationService;
var notifyDateTime = DateTime.Parse($"{DateTime.Now.ToShortDateString()} {settings.StudyAlertTime}");
var notification = new NotificationRequest
{
    NotificationId = 100,
    Title = AppResources.NotificationsTitle,
    Description = AppResources.NotificationDescription,
    CategoryType = NotificationCategoryType.Status,
    Android = new Plugin.LocalNotification.AndroidOption.AndroidOptions
    {
        AutoCancel = true,
        IconSmallName =
        {
            ResourceName = "noti_liulogo",
        },
        IconLargeName =
        {
            ResourceName = "liulogo",
        },
        LaunchAppWhenTapped = true,
        Priority = AndroidPriority.High
    },
    iOS =
    {
        HideForegroundAlert = true,
        PlayForegroundSound = true
    },
    Schedule =
    {
        NotifyTime = notifyDateTime,
        RepeatType = NotificationRepeat.Daily
    }
};

await _notificationService.Show(notification);

When the app runs this code, the user is redirected to the system page to enable Alarms and reminders but the switch is disabled.

enter image description here

What have I done wrong?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.