From 43d10d6c35ffd70581e0070365370ddafb5f4586 Mon Sep 17 00:00:00 2001 From: DCloud_JSON Date: Thu, 20 Jun 2024 15:31:22 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20unipush=20=E7=9A=84channel?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E9=85=8D=E7=BD=AE=EF=BC=8C=E9=98=B2=E6=AD=A2?= =?UTF-8?q?=E5=BA=94=E7=94=A8=E8=A2=AB=E9=81=BF=E5=85=8D=E8=A2=AB=E9=99=90?= =?UTF-8?q?=E9=87=8F=E6=8E=A8=E9=80=81=E3=80=81=E9=9D=99=E9=BB=98=E6=8E=A8?= =?UTF-8?q?=E9=80=81=EF=BC=88=E9=9D=99=E9=9F=B3=E4=B8=94=E9=9C=80=E4=B8=8B?= =?UTF-8?q?=E6=8B=89=E7=B3=BB=E7=BB=9F=E9=80=9A=E7=9F=A5=E6=A0=8F=E6=89=8D?= =?UTF-8?q?=E5=8F=AF=E8=A7=81=E9=80=9A=E7=9F=A5=E5=86=85=E5=AE=B9=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/config.js | 11 +++++++++++ sdk/init/index.js | 6 ++++-- sdk/init/msgEvent.js | 9 +++++++-- 3 files changed, 22 insertions(+), 4 deletions(-) create mode 100644 common/config.js diff --git a/common/config.js b/common/config.js new file mode 100644 index 0000000..0650fab --- /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 3bb353c..605dba3 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 f2f172a..e75a23f 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({ -- GitLab