我使用了 Push Plugin,当我发送带有动作按钮的推送时,即1) 接受 2) 忽略。
当通知到来时,我点击了“接受”按钮,但是我想要在“接受”按钮回调中获取参数。通过这个参数,我可以确定通知是用“接受”按钮调用的。
代码参考:
当通知到来时,我点击了“接受”按钮,但是我想要在“接受”按钮回调中获取参数。通过这个参数,我可以确定通知是用“接受”按钮调用的。
代码参考:
//initialization of push object
var push = PushNotification.init({
"android": {
"alert": "true",
"senderID": CONFIG.PROJECT_NUMBER,
"icon": "img/ionic.png",
"iconColor": "blue",
"badge": "true"
},
"ios": {
"alert": "true",
"badge": "true",
"sound": "true"
},
"windows": {
}
});
//listner for getting registration detail of device
push.on('registration', function(data) {
device_id_for_push=data.registrationId;
});
//listner called on new push notification
push.on('notification', function(data) {
// app.onPushAccept(data);
alert("on notification");
alert(JSON.stringify(data));
});
//error listner
push.on('error', function(e) {
// alert(e);
// alert("push error");
});
app.onPushAccept=function(data){
alert("onPushAccept")
alert(JSON.stringify(data));
// cordova.plugins.notification.badge.clear();
// cordova.plugins.notification.badge.increase();
}
在代码中,“app.onPushAccept”函数是“接受”按钮的回调函数。
请尽快帮我,谢谢。