uni-app uni.onPushMessage函数回调没有click类型只有receive

uni-app uni.onPushMessage函数回调没有click类型只有receive

信息类别 详细信息
产品分类 uniapp/App
PC开发环境操作系统 Windows
PC开发环境操作系统版本号 w11
HBuilderX类型 Alpha
HBuilderX版本号 4.61
手机系统 HarmonyOS NEXT
手机系统版本号 HarmonyOS NEXT Developer Beta2
手机厂商 华为
手机机型 nova 12 uitra
页面类型 vue
vue版本 vue3
打包方式 云端
项目创建方式 HBuilderX

示例代码:

uni.onPushMessage((res) => {  
    let push_clientid = uni.getStorageSync('push_clientid');  
    let loginInfo = getStorageWithExpiry('loginInfo');  
    if (!loginInfo) {  
        console.log('用户没有登录,禁止接收')  
        return  
    }  
    console.log('收到:', res)  
    setreaded()  
    const payload = res.data.payload  
    if (res.type == 'receive') {  
        console.log('开始播放音乐1')  
        // #ifdef APP-HARMONY  
        try {  
            uni.playmusic({  
                success: (res) => {  
                    console.log(res)  
                },  
                fail: (err) => {  
                    console.log(err)  
                }  
            })  

        } catch (ex) {  
            console(ex)  
        }  
        // #endif  
        // #ifndef APP-HARMONY  
        const innerAudioContext = uni.createInnerAudioContext();  
        innerAudioContext.src = '/static/msg.mp3'  
        innerAudioContext.play();  
        // #endif  

        const urlpage = res.data.payload.page  
        const title = res.data.title  
        const content = res.data.content  
        uni.showModal(  

            {  
                title: title,  
                content: content,  
                confirmText: "详情",  
                cancelText: "关闭",  
                sound: "none",  
                success: function(res) {  

                    if (res.confirm) {  
                        console.log('用户点击确定');  
                        let msgids = payload.msgids || [];  
                        let obj = {  
                            "push_clientid": "",  
                            "id": 0  
                        };  
                        const msgindex=msgids.findIndex(item => item.push_clientid ==  
                            push_clientid);  
                        if(msgindex>=0)  
                        {  
                            obj.push_clientid = msgids[msgindex].push_clientid;  
                            obj.id = msgids[msgindex].msgid;  
                        }                             
                        obj.msgtype = payload.msgtype;  
                        obj.content = content;  
                        obj.page=payload.page;  
                        //点击跳转到对应页面  
                        msggo.goto(obj);  

                    } else if (res.cancel) {  
                        //关闭不执行操作  

                    }  
                }  
            }  

        )  

    } else if (res.type == 'click') {  
         console.log("点击了横幅消息栏")  
        const content = res.data.content  
        let msgids = payload.msgids || [];  
        let obj = {  
            "push_clientid": "",  
            "id": 0  
        }  
        const msgindex = msgids.findIndex(item => item.push_clientid == push_clientid);  
        if (msgindex >= 0) {  
            obj.push_clientid = msgids[msgindex].push_clientid;  
            obj.id = msgids[msgindex].msgid  
        }  
        obj.page = payload.page;  

        //点击跳转到对应页面     
        obj.msgtype = payload.msgtype  
        obj.content = content  
        msggo.goto(obj);  

    }  

})

操作步骤:

  1. 发送鸿蒙消息
  2. 点击横幅消息
  3. 检查监听消息体中type无click类型

预期结果:

  1. 发送鸿蒙消息
  2. 点击横幅消息
  3. 检查监听消息体中type为click类型,且receive不应存在。

实际结果:

  1. 发送鸿蒙消息
  2. 点击横幅消息
  3. 检查监听消息体中type为click类型,且receive不应存在。

bug描述:

uni.onPushMessage函数回调没有click类型,只有receive


更多关于uni-app uni.onPushMessage函数回调没有click类型只有receive的实战教程也可以访问 https://www.itying.com/category-93-b0.html

1 回复

更多关于uni-app uni.onPushMessage函数回调没有click类型只有receive的实战教程也可以访问 https://www.itying.com/category-93-b0.html


请求体: { push_clientid: [ ‘7ebdebafe318dd8647f36667429da285’ ], title: ‘乔宝通知’, content: ‘5555发22222’, force_notification: false, request_id: undefined, payload: { page: ‘www.baidu.com’, msgids: [ [Object] ] }, options: { HW: { ‘/message/android/category’: ‘WORK’, ‘/message/android/ttl’: ‘86400s’, ‘/message/android/target_user_type’: 0, ‘/message/android/notification/default_sound’: false, ‘/message/android/notification/sound’: ‘/raw/pushsound’, ‘/message/android/notification/importance’: ‘NORMAL’ }, XM: { ‘/extra.sound_uri’: ‘android.resource://com.qiaoan.qiaoanqiaobao/raw/pushsound’, ‘/extra.channel_id’: 127529, ‘/time_to_live’: 86400000 }, XMG: { ‘/extra.channel_id’: ‘Default’ }, HO: { ‘/android/ttl’: ‘86400s’, ‘/android/notification/importance’: ‘NORMAL’ }, OP: { ‘/off_line’: true, ‘/off_line_ttl’: 86400 }, VV: { ‘/category’: ‘填写对应的ID’, ‘/notifyType’: 4, ‘/timeToLive’: 86400 } }, category: { harmony: ‘WORK’ }, sound: ‘pushsound’, channel: { XM: 127529, HW: ‘NORMAL’ } }

回到顶部