Flutter local notification with action buttons

5,669

Solution 1

Unfortunately, the flutter_local_notifications plugin does not support action buttons yet. There´s a feature request to add this.

I don´t know of any other plugins that support this, so i think right now the only possibility is to create your own custom plugin and develop it in native iOS code.

Solution 2

use awesome_notifications: ^0.0.6+7 package

Solution 3

awesome_notifications can be used to push notifications with action buttons.

Explanation:
This can be done by customizing the data (Json) received like:

{
    "to" : "[YOUR APP TOKEN]",
    "mutable_content" : true,
    "content_available": true,
    "priority": "high",
    "data" : {
        "content": {
            "id": 100,
            "channelKey": "big_picture",
            "title": "Huston!\nThe eagle has landed!",
            "body": "A small step for a man, but a giant leap to Flutter's community!",
            "notificationLayout": "BigPicture",
            "largeIcon": "https://media.fstatic.com/kdNpUx4VBicwDuRBnhBrNmVsaKU=/full-fit-in/290x478/media/artists/avatar/2013/08/neil-i-armstrong_a39978.jpeg",
            "bigPicture": "https://www.dw.com/image/49519617_303.jpg",
            "showWhen": true,
            "autoCancel": true,
            "privacy": "Private"
        },
        "actionButtons": [
            {
                "key": "REPLY",
                "label": "Reply",
                "autoCancel": true,
                "buttonType":  "InputField"
            },
            {
                "key": "ARCHIVE",
                "label": "Archive",
                "autoCancel": true
            }
        ],
        "schedule": {
            "timeZone": "America/New_York",
            "hour": "10",
            "minute": "0",
            "second": "0",
            "millisecond": "0",
            "allowWhileIdle": true,
            "repeat": true
        }
    }
}

and pushing notification with that messageData like:

AwesomeNotifications().createNotificationFromJsonData(yourReceivedMapData);
Share:
5,669
Thulasi Raman
Author by

Thulasi Raman

Updated on December 18, 2022

Comments

  • Thulasi Raman
    Thulasi Raman over 1 year

    I tried flutter local notification plugin in my flutter project its work fine on simple notifications but I need functionality of notifications with action buttons pls help me or suggest me to achieve this function.

  • Thulasi Raman
    Thulasi Raman over 4 years
    Thank you Josh I searched all.the resources but no way to achieve this. So started to create my own plugin
  • progNewbie
    progNewbie over 3 years
    @ThulasiRaman did you write an own plugin? If so, would you share it?