I want to add some action buttons to ionic push notification. I'm using cordova pushv5. The notifications works fine but I don't know how to add these buttons.
How do I add these buttons?
The Action Buttons should be added at the POST request.
{
"registration_ids": ["my device id"],
"data": {
"title": "AUX Scrum",
"message": "Scrum: Daily touchbase @ 10am Please be on time so we can cover everything on the agenda.",
"actions": [
{ "icon": "emailGuests", "title": "EMAIL GUESTS", "callback": "app.emailGuests", "foreground": true},
{ "icon": "snooze", "title": "SNOOZE", "callback": "app.snooze", "foreground": false}
]
}
}

https://github.com/phonegap/phonegap-plugin-push/blob/master/docs/PAYLOAD.md#action-buttons
In PushV5's notificationReceived event, you could pop up the notification with Ionic's Alert Component, which has customizable buttons.
$rootScope.$on('$cordovaPushV5:notificationReceived', function(event, data){
let alert = alertCtrl.create({
title: data.title,
message: data.message,
buttons: [
{
text: 'Nope',
handler: data => {
console.log('Nope clicked');
}
},
{
text: 'OK',
handler: data => {
console.log('OK clicked');
}
}
]
});
//popup the alert
alert.present();
});
https://ionicframework.com/docs/components/#alert
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With