ios有时会重复推几十条同一条消息,同时也有出现手机有响,但是没有看到通知在哪,代码处理如下
plus.push.addEventListener('click', function(msg) {
let payload = msg.payload;
console.log('click******',JSON.stringify(msg));
plus.nativeUI.alert(msg.content, function(){}, msg.title, "确定");
if (payload) {
if (typeof payload === 'string') {
try{
payload = JSON.parse(payload);
}catch(e){}
}
if (typeof payload === 'object') {
// payload.title:标题
// payload.content:通知消息的内容
// TODO ...
}
}
// msg ? _this.$tks.rewrite.showModal('click', JSON.stringify(msg)) : '';
});
plus.push.addEventListener('receive', function(msg) {
console.log('receive******',JSON.stringify(msg));
plus.push.createMessage(msg.content, msg.payload, {cover:false,title:msg.title});
// msg ? _this.$tks.rewrite.showModal('recevice', JSON.stringify(msg)) : '';
});
DCloud_App_Array
iOS平台plus.push.createMessage也会触发receive事件,需要像下面一样判断是否通过本地创建的:
2019-11-29 18:22