A***@163.com
A***@163.com
  • 发布:2019-11-06 17:08
  • 更新:2022-05-30 19:47
  • 阅读:1058

plus.push.createMessage打包后无效

分类:uni-app

我是使用websocket从后台获取的数据,然后想本地创建通知栏进行通知,打包安装后数据已经获取到,但是通知栏没有反应,因为是后台数据,所以我只在manifest.json文件app模块权限配置中勾选了push,请问一下,我是少了什么东西么,还是哪里错了?请指导!!!

uni.onSocketMessage(function(res) {
// console.log('收到服务器内容:' + res.data);
const result = JSON.parse(res.data); // {"msg":"23","type":"sendMessage"}
if (result.msg) {
console.log(result.msg);
//#ifdef APP-PLUS
uni.showModal({
title: '提示',
content: result.msg,
showCancel: false
});
const options = {
cover: false
};
plus.push.createMessage(result.msg, "LocalMSG", options); // 这步就无效

                /* 5+  push 消息推送 ps:使用:H5+的方式监听,实现推送*/  
                plus.push.addEventListener("click", function(msg) {  
                    uni.showModal({  
                        title: '1提示',  
                        content: msg,  
                        showCancel: false  
                    });  
                    console.log("click:" + JSON.stringify(msg));  
                    console.log(msg.payload);  
                    console.log(JSON.stringify(msg));  
                    //这里可以写跳转业务代码  
                }, false);  
                // 监听在线消息事件      
                plus.push.addEventListener("receive", function(msg) {  
                    // plus.ui.alert(2);    
                    //这里可以写跳转业务代码  
                    uni.showModal({  
                        title: '2提示',  
                        content: msg,  
                        showCancel: false  
                    });  
                    console.log("recevice:" + JSON.stringify(msg))  
                }, false);  
                //#endif   
            }  

        });  
2019-11-06 17:08 负责人:无 分享
已邀请:
A***@163.com

A***@163.com (作者) - 不会卖萌的菜鸟一枚

补充一下,今天打包可以接收到消息了,可是app退出的时候websocket也会断掉,请问各位有什么办法保持连接么,只要不是后台程序杀掉

1***@qq.com

1***@qq.com

onHide重新建立一个连接

低调小男孩

低调小男孩

怎么解决打包之后没有效果的?

要回复问题请先登录注册