Skip to content

dartnative_notifications: list pending notifications, schedule at a date, and read the permission status #120

Backlog

Description

@tayormi

Select your plan

Standard - priority support

Confirmations

  • I searched the existing feature requests and this is not a duplicate.

Framework or plugin?

Plugin

Platform

Both

Use case

dartnative_notifications 1.0.4 (bundled with 1.10.0) offers setup, getInitialTapPayload, requestPermission, show({id, title, body, payload, delaySeconds}), showChat, cancel, cancelAll and onTap (lib/src/dartnative_notifications.dart). Three things a reminder feature needs are missing:

  1. No way to list pending notifications. After scheduling show(id: 'n1', …) the app can't ask the OS whether n1 is still pending. We checked the simulator's own pending store to confirm scheduling and cancel work, but nothing in the API reads it.
  2. Scheduling is by delay only. show takes delaySeconds, so a reminder for 9:05 PM becomes target.difference(DateTime.now()).inSeconds. It fires after that many seconds of device time, so if the user changes the clock (or travels across zones) it fires at the wrong wall-clock time.
  3. No permission status read. requestPermission() returns the answer to the prompt, but there's no read of the current setting. If the user turns alerts back on in Settings, the app can't tell until it asks again.

We use it for "leave now" reminders before a night out. Our workaround is an app-side ledger (id → time, plus the last permission answer) in shared preferences, re-scheduled whenever the app opens. It can disagree with the OS: the app shows "Reminders are off" after the user re-enabled them in Settings, until the next save.

Proposal

Add three calls, mirroring flutter_local_notifications:

// iOS: UNUserNotificationCenter.getPendingNotificationRequests; Android: the plugin's own record of scheduled alarms
static Future<List<PendingNotification>> pending(); // {id, title, body, payload, fireAt?}

// iOS: UNCalendarNotificationTrigger; Android: an exact alarm at that time
static void show({required String id, required String title, String body = '',
                  String payload = '', int delaySeconds = 0, DateTime? at});

// UNUserNotificationCenter.getNotificationSettings / NotificationManagerCompat.areNotificationsEnabled
static Future<NotificationPermission> permissionStatus(); // granted, denied, notDetermined, provisional

at and delaySeconds would be mutually exclusive.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions