使用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
})
0 个回复