需求是后端推送的消息APP要响自定义语音,利用官方插件,总结下整体流程
uniapp后台配置
因为2.0只支持uniapp自己的后台发送消息,所以要自己的后台发送消息只能用1.0
插件地址和代码
插件地址: link
let isIos = (plus.os.name == "iOS");if (isIos) {setCustomPushChannel({soundName: 'ceshi',channelId: 'ceshi',channelDesc: 'ceshi',enableLights: true,enableVibration: true,importance: 4,lockscreenVisibility: 1});} else {const plugin = uni.requireNativePlugin("DCloud-PushSound");setTimeout(() => {plugin.setCustomPushChannel({soundName: 'ceshi',channelId: 'ceshi',channelDesc: 'ceshi',enableLights: true,enableVibration: true,importance: 4,lockscreenVisibility: 1});}, 500)}