diff --git a/common/config.js b/common/config.js new file mode 100644 index 0000000000000000000000000000000000000000..0650fabec0167cab703c923f379c71b3c7c323c9 --- /dev/null +++ b/common/config.js @@ -0,0 +1,11 @@ +export default { + uniPush: { + // 消息渠道设置,避免被限量推送、静默推送(静音且需下拉系统通知栏才可见通知内容)详情文档:https://doc.dcloud.net.cn/uniCloud/uni-cloud-push/api.html#channel + channel:{ + // 渠道id + id: "114240", + // 消息渠道描述,会显示在手机系统关于当前应用的通知设置中 + desc: "客服消息" + } + } +} \ No newline at end of file diff --git a/sdk/init/index.js b/sdk/init/index.js index 3bb353ca2b23b5c62e6f01b4f8ec618988d05af3..605dba3acab44fad4946f414e5740327d2f4bd5b 100644 --- a/sdk/init/index.js +++ b/sdk/init/index.js @@ -1,3 +1,4 @@ +import config from '@/uni_modules/uni-im/common/config.js'; import $state from '@/uni_modules/uni-im/sdk/state/index.js'; import $methods from '@/uni_modules/uni-im/sdk/methods/index.js'; import {init as initIndexDB} from '@/uni_modules/uni-im/sdk/ext/indexDB.js'; @@ -15,6 +16,7 @@ import onSocketStateChange from './onSocketStateChange' import imData from './imData' import onlyOneWebTab from './onlyOneWebTab' + // #ifdef APP // import sqlite from './sqlite.js' // #endif @@ -165,8 +167,8 @@ export default async function (initParam) { plugin.setCustomPushChannel( { // soundName: "pushsound", - channelId: "114240", - channelDesc: "客服消息", + channelId: config.uniPush.channel.id, + channelDesc: config.uniPush.channel.desc, enableLights: true, enableVibration: true, importance: 4, diff --git a/sdk/init/msgEvent.js b/sdk/init/msgEvent.js index f2f172a7f812dce4821de1efa883bebdc40979a5..e75a23f561a832caa50903c0f52d1029d5b449f2 100644 --- a/sdk/init/msgEvent.js +++ b/sdk/init/msgEvent.js @@ -1,3 +1,4 @@ +import config from '@/uni_modules/uni-im/common/config.js'; import $utils from '@/uni_modules/uni-im/sdk/utils/index.js'; import $extensions from '@/uni_modules/uni-im/sdk/methods/extensions.js'; import $state from '../state/index.js'; @@ -193,9 +194,13 @@ msgEvent.onMsg(async res=>{ icon = downloadFileRes[1]?.tempFilePath } } - plus.push.createMessage(content, payload, { + uni.createPushMessage({ title, - icon + content, + payload, + icon, + channelId: config.uniPush.channel.id, + category: 'IM', }) } else if (conversation_id != $state.currentConversationId) { // uni.showToast({