tenko
tenko

Reputation: 171

Show actions with Ionic push notifications

I am trying to implement notification Actions using Ionic custom push notifications and the phonegap-plugin-push.

Unfortunately, even if message and title work perfectly, I didn't have any luck showing the actions buttons yet.

This is my cURL request:

curl -X POST -H "Authorization: Bearer XXXXXXXXXXXXXXX" -H "Content-Type: application/json" -d '{
"tokens": ["XXXXXXXXXXXXXXX"],
"profile": "push01",
"notification": {
    "message": "test",
    "android": {
      "title": "test android",
      "data": {
        "actions": [
          { "icon": "emailGuests", "title": "EMAIL GUESTS", "callback": "app.emailGuests", "foreground": true},
          { "icon": "snooze", "title": "SNOOZE", "callback": "app.snooze", "foreground": false }
        ]
      }
    }
  }
}' "https://api.ionic.io/push/notifications"

Any idea on what I might be doing wrong?

Thanks!

Upvotes: 5

Views: 667

Answers (2)

Jack Vial
Jack Vial

Reputation: 2474

The callback function "app.emailGuests" needs to be accessible from the global scope.

Something like this:

window.app = {};
window.app.emailGuests = function(data){
    // Do stuff when button is clicked
    console.log('Notification data: ', data);
};

Upvotes: 1

tenko
tenko

Reputation: 171

Apparently there was some sort of incompatibility issues with some of the SDK library versions.

See this as reference: https://github.com/phonegap/phonegap-plugin-push/issues/767

Upvotes: 1

Related Questions