点击通知只能打开APP无法跳转页面怎么回事?
- 发布:2020-11-04 09:14
- 更新:2020-11-04 09:43
- 阅读:823
一样的,点击没有进行跳转;好像连弹窗都没弹出来
-
回复 f***@163.com: //判断客户端
var clent = uni.getSystemInfoSync().platform
plus.push.setAutoNotification(true)
const _self = this;
//收到透传消息
//只有APP在线时,才会触发receive事件,透传消息不会触发系统消息,需要创建本地消息
plus.push.addEventListener("receive", function(msg) {
var clent = uni.getSystemInfoSync().platform
console.log("(receive):" + JSON.stringify(msg));
uni.showToast({
title: JSON.stringify(msg),
icon: "none"
});
if (clent == 'ios') { //如果是IOS
var payload = msg.payload;
//【APP离线】收到消息,但没有提醒(发生在一次收到多个离线消息时,只有一个有提醒,但其他的没有提醒)
//【APP在线】收到消息,不会触发系统消息,需要创建本地消息,但不能重复创建。必须加msg.type验证去除死循环
if (msg.aps == null && msg.type == "receive") {
var messageTitle = payload.messageTitle;
var messageContent = payload.messageContent;
//创建本地消息,发送的本地消息也会被receive方法接收到,但没有type属性,且aps是null
plus.push.createMessage(messageContent, JSON.stringify(payload), {
title: messageTitle
});
}
// else{
// var payload = JSON.parse(msg.payload);
// plus.push.createMessage(payload.messageContent, JSON.stringify(payload.payload), {title: payload.messageTitle});
// }
}
if (clent == 'android') {
//如果是Android,当APP在线时,收到透传消息不会进入系统消息,需要发送本地提醒。
var payload = JSON.parse(msg.content);
var messageTitle = payload.messageTitle;
var messageContent = payload.messageContent;
plus.push.createMessage(messageContent, msg.payload, {
title: messageTitle
});
plus.runtime.setBadgeNumber(1)
}
}, false);
//消息点击事件
//【APP在线】,收到透传消息通过,不会提醒至通知栏目,需要发送本地消息,再进行点击触发的点击事件。
//【APP离线】,收到离线透传消息,必须通过Java后台的Intent字符串携带payload,且符合格式才能触发click事件,格式不符合不会触发
plus.push.addEventListener("click", function(msg) {
var clent = uni.getSystemInfoSync().platform
console.log("(click):" + JSON.stringify(msg));
uni.showToast({
title: JSON.stringify(msg),
icon: "none"
});
if (clent == 'ios') { //如果是IOS
var payload;
if (msg.type == "click") { //APP离线点击包含click属性,这时payload是JSON对象
payload = msg.payload;
} else { //APP在线,收到消息不会包含type属性,这时的payload是JSON字符串,需要转为JSON对象
payload = JSON.parse(msg.payload);
}
if (payload != null || payload != undefined) {
console.log("payload:" + payload)
//_self.callback(payload+"");
_self.setUniPush_state("1")
_self.setUniPush_url(payload.payload)
uni.reLaunch({
url: '/pages/index/index'
})
}
}
if (clent == 'android') { //如果是Android,收到playload均是是JSON字符串,需要转为JSON对象
var payload = msg.payload;
console.log("msg.payload:" + msg.payload)
if (payload != null || payload != undefined) {
console.log("payload:" + payload)
// _self.callback(payload+"");
_self.setUniPush_state("1")
_self.setUniPush_url(payload)
uni.reLaunch({
url: '/pages/social/social'
})
}
}
}, false);2020-11-04 10:12
f***@163.com (作者)
还是不行
2020-11-04 09:34