我用过 Push Plugin,当我发送带按钮的按钮1)接受2)忽略. 通知来的时候,我点击了“接受”按钮.但我希望参数与“接受”按钮回调.从那我将识别与通知的“接受”被称为. 代码参考 //initia
通知来的时候,我点击了“接受”按钮.但我希望参数与“接受”按钮回调.从那我将识别与通知的“接受”被称为.
代码参考
//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”函数是“接受”按钮的回调..
请尽快帮助我.
谢谢..
第1步 – 首先转到下面的目录
plugins > phonegap-plugin-push > src > android > com > adobe > phonegap > push
第2步 – 从上面的目录中打开GCMIntentService.java文件
第3步 – 确定调用“createActions”的函数和
添加实际参数“requestCode”就像…
createActions(extras,mBuilder,resources,packageName,notId,requestCode);
第4步 – 确定函数定义“createActions”和
添加形式参数“int requestCode”就像…
private void createActions(Bundle extras, NotificationCompat.Builder mBuilder, Resources resources, String packageName, int notId,int requestCode)
第5步 – 在函数定义“createActions”中,在for循环中
将第二个参数从“i”更改为“requestCode”,如…
pIntent = PendingIntent.getActivity(this, requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT);
pIntent = PendingIntent.getBroadcast(this, requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT);
第6步 – 完成上述所有步骤后删除android平台如果已添加平台则添加android平台.
抱歉,如果我的解决方案中发现任何错误,请改进.
