使用了unipush2插件,离线消息可以正常接收,但是点击通知栏的消息时,在uni.onPushMessage中监听不到消息信息。在线消息可以监听到。以下是相关代码:
onLaunch: function () {
// 初始化unipush
uni.onPushMessage((res) => {
console.log("res:"+JSON.stringify(res))
if(res.type=='receive'){
console.log("res111:"+JSON.stringify(res))
uni.createPushMessage({
content:res.data.content,
sound: 'system',
cover: true
})
}else if(res.type=='click'){
console.log("res222:"+JSON.stringify(res))
plus.runtime.setBadgeNumber(0);
// 跳转
if(location){
location.href = res.data.payload.openUrl
}else{
uni.navigateTo({
url: "/pages/webView?src=" + res.data.payload.openUrl.split('&').join('^^^^')
});
}
}
})
uni.getPushClientId({
success: res=>{
uni.setStorageSync('cid', res.cid);
}
})
console.log('uni-push Launch')
}
2***@qq.com
用plus.push.addEventListener('click', function (msg) {})监听到了
2024-08-23 16:20