- 发布:2023-07-01 09:49
- 更新:2023-07-03 12:07
- 阅读:315
产品分类: uniapp/App
PC开发环境操作系统: Windows
PC开发环境操作系统版本号: Windows 11 专业版 22H2
HBuilderX类型: 正式
HBuilderX版本号: 3.8.4
手机系统: 全部
手机厂商: 华为
页面类型: nvue
vue版本: vue2
打包方式: 云端
项目创建方式: HBuilderX
测试过的手机:
示例代码:
function pushNotice({
title,
content,
sound = true,
cover = true,
delay = 0,
payload,
click,
icon,
success,
error,
}) {
uni.offPushMessage();
uni.createPushMessage({
title: title || "测试",
content: content,
sound: sound ? "system" : "none",
cover: cover,
delay: delay,
icon: icon ? icon : "",
payload: payload ? payload : {},
success: (res) => {
success && success(res);
uni.onPushMessage((e) => {
click && click(e);
uni.offPushMessage();
});
},
fail: (err) => {
error && error(err);
},
});
}
pushNotice({
title: "测试",
content: "通知测试",
payload: {
page: {
pages: "/pages/index/index",
type: "default",
},
},
click: (res) => {
switch (res.data.payload.page.type) {
case "new":
uni.redirectTo({
url: res.data.payload.page.pages,
});
break;
case "tabBar":
uni.switchTab({
url: res.data.payload.page.pages,
});
break;
default:
uni.navigateTo({
url: res.data.payload.page.pages,
});
break;
}
},
success: (e) => {},
error: (err) => {},
});
function pushNotice({
title,
content,
sound = true,
cover = true,
delay = 0,
payload,
click,
icon,
success,
error,
}) {
uni.offPushMessage();
uni.createPushMessage({
title: title || "测试",
content: content,
sound: sound ? "system" : "none",
cover: cover,
delay: delay,
icon: icon ? icon : "",
payload: payload ? payload : {},
success: (res) => {
success && success(res);
uni.onPushMessage((e) => {
click && click(e);
uni.offPushMessage();
});
},
fail: (err) => {
error && error(err);
},
});
}
pushNotice({
title: "测试",
content: "通知测试",
payload: {
page: {
pages: "/pages/index/index",
type: "default",
},
},
click: (res) => {
switch (res.data.payload.page.type) {
case "new":
uni.redirectTo({
url: res.data.payload.page.pages,
});
break;
case "tabBar":
uni.switchTab({
url: res.data.payload.page.pages,
});
break;
default:
uni.navigateTo({
url: res.data.payload.page.pages,
});
break;
}
},
success: (e) => {},
error: (err) => {},
});
操作步骤:
安卓和iPhone13处于后台或前台时,接收到socket发送的消息,app通过uni.createPushMessage发送本地通知,当app处于后台或者退出前台时,点击通知无法唤起app
安卓和iPhone13处于后台或前台时,接收到socket发送的消息,app通过uni.createPushMessage发送本地通知,当app处于后台或者退出前台时,点击通知无法唤起app
预期结果:
点击通知正常打开app
点击通知正常打开app
实际结果:
iPhone12点击通知正常打开app,安卓和iPhone13点击通知无法打开app
iPhone12点击通知正常打开app,安卓和iPhone13点击通知无法打开app
bug描述:
安卓和iPhone13后台时接收到由socket发送的消息,app通过uni.createPushMessage发送通知,安卓、iPhone13在后台时点击通知无法唤起app,但是app内部已经完成页面跳转,iPhone12正常
1 个回复
DCloud_uniCloud_JSON
为缩小问题排查范围,请简化调用push模块的参数和示例逻辑,测试时把点击回调参数console.log出来看看。如果仍然能复现问题,请提供新示例代码