Flutter: How Can I Add buttons to Local Notification
Asked Answered
S

1

16

i've been able to show Local Notification but is there any option to show buttons below the notification?

(See "Snooze" & "Dismiss" button in the attached picture).

enter image description here

Serration answered 19/9, 2018 at 14:27 Comment(3)
Can you post the code for showing local notification?Hellraiser
Checkout this medium post might be helpful for you medium.com/@info_67212/…Sentry
Late but checkout this plugin github.com/mitchhymel/local_notificationsHom
M
3

If you are using local_notifications you can add actions:

handleCustomActionClick(String payload) {
    if(payload == "secondAction") {
        LocalNotifications.removeNotification(0);
    }
}

int id = await LocalNotifications.createNotification(
    title: "Multiple Actions",
    content: 'With custom callbacks',
    id: 0,
    onNotificationClick: new NotificationAction(
        actionText: "Some action",
        callback: onNotificationClick,
        payload: "Some payload",
        launchesApp: false
    ),
    actions: [
        new NotificationAction(
            actionText: "First",
            callback: handleCustomActionClick,
            payload: "firstAction",
            launchesApp: true
        ),
        new NotificationAction(
            actionText: "Second",
            callback: handleCustomActionClick,
            payload: "secondAction",
            launchesApp: false
        )
    ]
);
Makeyevka answered 2/1, 2020 at 20:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.