9***@qq.com
9***@qq.com
  • 发布:2025-08-15 16:12
  • 更新:2025-09-19 17:35
  • 阅读:96

unipush 自定义铃声华为不生效

分类:uni-app

使用uniapp ,云函数推送,目前华为可以收到离线消息,但是自定义铃声不生效,本机测试渠道“test2”可以出发响铃

  const res = await uniPush.sendMessage({  
    push_clientid: obj.cids, // 设备 ID 数组  
    title: obj.title,  
    content: obj.content,  
    payload: obj.payload, // 自定义数据  
    // 华为离线推送参数  
    options: {  
      HW: {  
        '/message/android/target_user_type': 1,  
        '/message/android/notification/channel_id': 'test2', // 必须和 App 端注册的 channelId 一致  
        '/message/android/notification/default_sound': false, // 不用默认声音  
        '/message/android/notification/sound': '/raw/misic', // 声音路径  
        '/message/android/notification/importance': 'HIGH', // 高优先级  
        '/message/android/category': 'VOIP', // VOIP 类型  
      },  
    },  
  })  

 const plugin = uni.requireNativePlugin('DCloud-PushSound')  

    plugin.setCustomPushChannel(  
      {  
        soundName: 'misic',  
        channelId: 'test2',  
        channelDesc: 'test2渠道描述',  
        enableLights: true,  
        enableVibration: true,  
        importance: 4,  
        lockscreenVisibility: 1,  
      },  
      (e) => {  
        console.log('创建失败')  
      }  
    )  
    plugin.getAllChannels((p) => {  
      console.log('channels :' + JSON.stringify(p)) //返回数组  
    })  
    plugin.testNotification({  
      channelId: 'test2', //渠道id  
    })
2025-08-15 16:12 负责人:无 分享
已邀请:
套马杆的套子

套马杆的套子 - 没有解决不了的问题,只有解决不完的问题

1.下子插件了么 https://ext.dcloud.net.cn/plugin?id=7482

  1. /raw/misic 有这个文件么
  2. 这个代码,需要放到APP.vue中吧,  
    const plugin = uni.requireNativePlugin('DCloud-PushSound')    
    
    plugin.setCustomPushChannel(    
      {    
        soundName: 'misic',    
        channelId: 'test2',    
        channelDesc: 'test2渠道描述',    
        enableLights: true,    
        enableVibration: true,    
        importance: 4,    
        lockscreenVisibility: 1,    
      },    
      (e) => {    
        console.log('创建失败')    
      }    
    )    
    plugin.getAllChannels((p) => {    
      console.log('channels :' + JSON.stringify(p)) //返回数组    
    })    
    plugin.testNotification({    
      channelId: 'test2', //渠道id    
    })
  • 9***@qq.com (作者)

    下插件了;/raw/misic 这个文件有;那段代码放在app.vue中的;调用plugin.testNotification({

    channelId: 'test2', //渠道id

    })代码可以正常播放音乐

    2025-08-20 16:58

9***@qq.com

9***@qq.com (作者)

这么写也不行,哭死{
"cids": ["4ffe2b9fe357833b489e74a8da637ee5"],
"title": "视频通话邀请1",
"content": "111 ",
"payload": {
"type": "call_request",
"data1": 1,
"data2": 2
},
"category": {
"huawei": "IM"
},
//这个options是离线通知需要配置不同的厂商
"options": {
"HW": {
// 值为int 类型。1 表示华为测试消息,华为每个应用每日可发送该测试消息500条,此target_user_type 参数请勿发布至线上。
"/message/android/target_user_type": 1,
"/message/android/category": "IM"
},
"android": {
"HW": {
"/message/android/notification/default_sound": false,
"/message/android/notification/channel_id": "test2",
"/message/android/notification/sound": "/raw/misic"
}
}
}
}

l***@163.com

l***@163.com - 学历只是过去,学习决定未来

华为国内手机不支持自定义铃声吧?

要回复问题请先登录注册