2***@qq.com
2***@qq.com
  • 发布:2020-10-16 10:51
  • 更新:2021-03-19 15:15
  • 阅读:1948

【报Bug】plus.push.addEventListener(receive) 无法监听华为厂商推送

分类:uni-app

产品分类: uniapp/App

PC开发环境操作系统: Windows

PC开发环境操作系统版本号: WIN7

HBuilderX类型: 正式

HBuilderX版本号: 2.9.3

手机系统: Android

手机系统版本号: Android 9.0

手机厂商: 华为

手机机型: COL-AL10

页面类型: vue

打包方式: 云端

项目创建方式: HBuilderX

App下载地址或H5⽹址: https://service.dcloud.net.cn/build/download/5b3014a0-0f57-11eb-81f4-4f1e219485d5

示例代码:

<script>
export default {
onLaunch: function() {
console.log('App Launch')

        var info = plus.push.getClientInfo();  
        console.log(JSON.stringify(info));  
        plus.nativeUI.toast(info.clientid);  
        /* 5+  push 消息推送 ps:使用:H5+的方式监听,实现推送*/  
        plus.push.addEventListener("click", function(msg) {  
            plus.nativeUI.toast('push click');  
            //这里可以写跳转业务代码  
        }, false);  
        // 监听在线消息事件      
        plus.push.addEventListener("receive", function(msg) {  
            alert("2");  
            //这里可以写跳转业务代码  

        }, false);  
    },  
    onShow: function() {  
        console.log('App Show')  
    },  
    onHide: function() {  
        console.log('App Hide')  
    }  
}  

</script>

<style lang="scss">
@import "uview-ui/index.scss";
/每个页面公共css /
</style>

操作步骤:

<script>
export default {
onLaunch: function() {
console.log('App Launch')

        var info = plus.push.getClientInfo();  
        console.log(JSON.stringify(info));  
        plus.nativeUI.toast(info.clientid);  
        /* 5+  push 消息推送 ps:使用:H5+的方式监听,实现推送*/  
        plus.push.addEventListener("click", function(msg) {  
            plus.nativeUI.toast('push click');  
            //这里可以写跳转业务代码  
        }, false);  
        // 监听在线消息事件      
        plus.push.addEventListener("receive", function(msg) {  
            alert("2");  
            //这里可以写跳转业务代码  

        }, false);  
    },  
    onShow: function() {  
        console.log('App Show')  
    },  
    onHide: function() {  
        console.log('App Hide')  
    }  
}  

</script>

<style lang="scss">
@import "uview-ui/index.scss";
/每个页面公共css /
</style>

预期结果:

plus.push.addEventListener("receive", function(msg) {
alert("2");
/这里可以写跳转业务代码
}, false);

监听到推送消息信息 并且弹出alert 2的页面

实际结果:

推送收到以后没有任何反应

bug描述:

unipush华为厂商推送 plus.push.addEventListener(receive) 无法监听到 这个监听程序根本没有触发 而且华为厂商推送 只响铃不震动不知道是什么原因?

我的监听写在了App.vue里面以下是全部代码:
<script>
export default {
onLaunch: function() {
console.log('App Launch')

        var info = plus.push.getClientInfo();  
        console.log(JSON.stringify(info));  
        plus.nativeUI.toast(info.clientid);  
        /* 5+  push 消息推送 ps:使用:H5+的方式监听,实现推送*/  
        plus.push.addEventListener("click", function(msg) {  
            plus.nativeUI.toast('push click');  
            //这里可以写跳转业务代码  
        }, false);  
        // 监听在线消息事件      
        plus.push.addEventListener("receive", function(msg) {  
            alert("2");  
            //这里可以写跳转业务代码  

        }, false);  
    },  
    onShow: function() {  
        console.log('App Show')  
    },  
    onHide: function() {  
        console.log('App Hide')  
    }  
}  

</script>

<style lang="scss">
@import "uview-ui/index.scss";
/每个页面公共css /
</style>

2020-10-16 10:51 负责人:无 分享
已邀请:
AIHV

AIHV - 有脏东西

最后怎么解决的,我也遇到了

  • AIHV

    解决了,参考 https://www.it610.com/article/1290091371675328512.htm

    后端推送数据结构修改一下就行了,链接里有前后端代码

    2021-04-01 11:13

该问题目前已经被锁定, 无法添加新回复