uni-app plus.push.createMessage 云打包无法在通知栏创建消息
uni-app plus.push.createMessage 云打包无法在通知栏创建消息
示例代码:
try {
plus.push.setAutoNotification(true);
plus.push.createMessage(content, payload, {
title,
cover: false
});
console.log('plus.push 成功');
uni.showToast({
title:'plus.push 成功' //这个弹框有在app出现,但是没有在通知栏创建信息
})
} catch(err) {
uni.showToast({
title: 'plus.push 失败',
});
console.log('plus.push 失败',err);
}
```
## 操作步骤:
APP 是使用websocket ,链接的,收到socket消息就在本地创建消息,真机测试偶尔无法在通知栏创建消息,APP打开太久也无法在通知栏创建消息,测试的时候uni.showToast() 这个方法有执行,说明执行plus.push.createMessage方法,云打包之后也无法在通知栏创建消息,uni.showToast() 这个弹框有执行
## 预期结果:
可以在通知栏创建消息
## 实际结果:
APP云打包,真机测试偶尔或者APP打开太久都无法在通知栏创建消息
## bug描述:
plus.push.createMessage 使用这个方法 ,真机测试偶尔也是无法创建消息,云打包之后没有在通知栏创建消息
```
| 信息 | 描述 |
|----------------|--------------------------------------------|
| 产品分类 | HTML5+ |
| HBuilderX版本号 | 3.3.13 |
| 手机系统 | Android |
| 手机系统版本号 | Android 9.0 |
| 手机厂商 | note9 |
| 手机机型 | M923Q |
| 打包方式 | 云端 |
更多关于uni-app plus.push.createMessage 云打包无法在通知栏创建消息的实战教程也可以访问 https://www.itying.com/category-93-b0.html
1 回复
更多关于uni-app plus.push.createMessage 云打包无法在通知栏创建消息的实战教程也可以访问 https://www.itying.com/category-93-b0.html
在使用 uni-app
的 plus.push.createMessage
方法时,如果云打包后无法在通知栏创建消息,可能是由于以下几个原因导致的。你可以按照以下步骤进行排查和解决:
1. 检查权限配置
确保在 manifest.json
文件中正确配置了推送相关的权限。例如:
{
"permissions": {
"Push": {
"description": "推送权限"
}
}
}
2. 检查推送服务配置
确保在 manifest.json
中正确配置了推送服务。例如,如果你使用的是个推(Getui),需要配置如下:
{
"push": {
"getui": {
"appid": "你的AppID",
"appkey": "你的AppKey",
"appsecret": "你的AppSecret"
}
}
}
3. 检查云打包配置
在云打包时,确保选择了正确的推送服务插件。例如,如果你使用的是个推,需要在云打包时勾选个推插件。
4. 检查代码逻辑
确保在代码中正确调用了 plus.push.createMessage
方法。例如:
plus.push.createMessage({
content: "这是一条测试消息",
payload: "test",
title: "测试标题"
}, function() {
console.log("消息创建成功");
}, function(e) {
console.log("消息创建失败: " + JSON.stringify(e));
});