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

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 负责人:无 分享
已邀请:

要回复问题请先登录注册