[英]Show actions with Ionic push notifications
I am trying to implement notification Actions using Ionic custom push notifications and the phonegap-plugin-push . 我正在尝试使用Ionic 自定义推送通知和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请求:
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! 谢谢!
Apparently there was some sort of incompatibility issues with some of the SDK library versions. 显然,某些SDK库版本存在某种不兼容问题。
See this as reference: https://github.com/phonegap/phonegap-plugin-push/issues/767 请参阅此参考: https : //github.com/phonegap/phonegap-plugin-push/issues/767
The callback function "app.emailGuests" needs to be accessible from the global scope. 需要可以从全局范围访问回调函数“app.emailGuests”。
Something like this: 像这样的东西:
window.app = {};
window.app.emailGuests = function(data){
// Do stuff when button is clicked
console.log('Notification data: ', data);
};
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.