Skip to content Skip to sidebar Skip to footer

Flutter Local Notification With Action Buttons

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 s

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);

Post a Comment for "Flutter Local Notification With Action Buttons"