我想在离子推送通知中添加一些操作按钮。我使用的是cordova pushv5。通知工作正常,但我不知道如何添加这些按钮。
如何添加这些按钮?
答案 0 :(得分:4)
应在POST请求中添加操作按钮。
{
"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
答案 1 :(得分:0)
在PushV5的notificationReceived事件中,您可以使用Ionic的警报组件弹出通知,该组件具有可自定义的按钮。
$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();
});