0
votes

I am using ionic4 with push plugin to send the push notifications with FCM.

I could able to send the notifications, but some reason action buttons are not getting displayed in notifications only title and body content getting displayed.

Following is the payload of my request:

{
    "to": "eoD5PLNgj3A:APA91bHcrWcEfbEQuKGOozPXtIxO7CrN2Gd993bXcaaHSO8BkOXhwJ4x1o-7SIUEzIUVLxSwcKih1ac0jOkj4Jp8LQZkRiAHAEfRvRGopSAP4JkJVKXoRllxSkAUCAxWGCfUTk3umMsn",
    "registration_ids": null,
    "condition": null,
    "collapse_key": null,
    "content_available": null,
    "mutable_content": null,
    "priority": "high",
    "time_to_live": 900,
    "dry_run": false,
    "data": {
        "title": "New Visitor",
        "message": "Suda Sankara Rao is here to see you at Protoco HQ.\r\n",
        "visit_id": "ae866080-b6af-44cd-944c-6491ae9d2e4b",
        "force-start": 1,
        "visibility": 1,
        "notId": "ae866080-b6af-44cd-944c-6491ae9d2e4b",
        "actions": [{
            "icon": "snooze",
            "title": "Accept",
            "callback": "visit.accept",
            "foreground": false
        }, {
            "icon": "snooze",
            "title": "Reject",
            "callback": "visit.reject",
            "foreground": true
        }]
    },
    "notification": {
        "title": "New Visitor",
        "body": "Suda Sankara Rao is here to see you at Protoco HQ.\r\n",
        "click_action": "visit",
        "badge": null,
        "android_channel_id": null,
        "icon": null,
        "sound": null,
        "tag": "ae866080-b6af-44cd-944c-6491ae9d2e4b",
        "color": null,
        "body_loc_key": null,
        "body_loc_args": null,
        "title_loc_key": null,
        "title_loc_args": null
    }
}

Receiving the notification data in below format to a device:

{
    "title": "New Visitor",
    "message": "Suda Sankara Rao is here to see you at Protoco HQ.",
    "additionalData": {
        "actions": [{
            "callback": "accept",
            "foreground": false,
            "title": "Accept"
        }, {
            "callback": "reject",
            "foreground": true,
            "title": "Reject"
        }],
        "visit_id": "ae866080-b6af-44cd-944c-6491ae9d2e4b",
        "coldstart": false,
        "foreground": true
    }
}

Ionic Info:

Ionic:

   Ionic CLI                     : 5.4.15 (/usr/local/lib/node_modules/ionic)
   Ionic Framework               : @ionic/angular 4.11.8
   @angular-devkit/build-angular : 0.801.3
   @angular-devkit/schematics    : 8.1.3
   @angular/cli                  : 8.1.3
   @ionic/angular-toolkit        : 2.1.2

Cordova:

   Cordova CLI       : 9.0.0 ([email protected])
   Cordova Platforms : android 8.1.0, ios 5.1.1
   Cordova Plugins   : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 4.1.3, (and 9 other plugins)

Push plugin version: [email protected]

I could not able to figure out the issue.

I am using an android emulator to test the notifications.

1

1 Answers

0
votes

I could able to identify and resolve the issue.

if the payload has notification object. Action buttons are not visible.

I have removed and worked fine.