| iPhone 13 | 三星 Galaxy A23 海外版(Google FCM 推送) |
manifestPlaceholders.json
和 mcs-services.json
。nativeResources
目录下进行推送配置。若项目根目录尚未创建该文件夹,请新建一个名为 nativeResources
的文件夹。nativeResources
目录存在,且与 uni_modules
目录平级。nativeResources/android/assets
目录。timpush-configs.json
(在 推送 > 接入设置 > 一键式快速配置 下载),到 nativeResources/android/assets/
目录下。如图所示:com.google.gms.google-services
到 uni_modules/TencentCloud-Push/utssdk/app-android/config.json
的 project.plugins
中,如下所示:"project": {"plugins": [..."com.google.gms.google-services"],"dependencies": ["com.huawei.agconnect:agcp:1.9.1.301","com.google.gms:google-services:4.3.15","com.hihonor.mcs:asplugin:2.0.1.300"]}
google-services.json
文件到 nativeResources/android/
目录下(注意!请勿配置到 nativeResources/android/asstes
目录下)。如图所示:agconnect-services.json
(此文件获取详见 厂商配置 > uniapp > 华为 > 步骤4:获取应用信息)到 nativeResources/android/assets/
目录下。如图所示:uni_modules/TencentCloud-Push/utssdk/app-android/config.json
的 dependencies
,添加 "com.tencent.timpush:honor:8.3.6498"
。{..."dependencies": [..."com.tencent.timpush:honor:8.3.6498"]}
mcs-services.json
文件到 nativeResources/android
(此文件获取详见 厂商配置 > uniapp > 荣耀 > 步骤3.2:进入应用详情, 绑定应用包名,下载 mcs-services.json 文件)目录下。如图所示:appID
到 nativeResources/android/manifestPlaceholders.json
中的 "HONOR_APPID"
。{"HONOR_APPID": ""}
uni_modules/TencentCloud-Push/utssdk/app-android/config.json
的 dependencies
,添加 "com.tencent.timpush:vivo:8.3.6498"
。{..."dependencies": [..."com.tencent.timpush:vivo:8.3.6498"]}
appID
和 appKey
到 nativeResources/android/manifestPlaceholders.json
中的 VIVO_APPKEY
和 VIVO_APPID
。{"VIVO_APPKEY": "","VIVO_APPID": "",}
nativeResources/ios/Resources
目录;nativeResources/ios/Resources
中新建 timpush-configs.json
文件;timpush-configs.json
文件中。如下所示:{"businessID":"xxx"}
import { TUILogin } from '@tencentcloud/tui-core';import { TUIConversationService } from '@tencentcloud/chat-uikit-engine';import * as Push from '@/uni_modules/TencentCloud-Push';const SDKAppID = 0; // 您的 SDKAppIDconst appKey = ''; // 客户端密钥const userID = ''; // 您的 userIDconst userSig = ''; // 您 userID 的密钥let vueVersion = 2;// #ifdef VUE3vueVersion = 3;// #endifTUILogin.login({SDKAppID,userID,userSig,useUploadPlugin: true,framework: `vue${vueVersion}`,}).then(() => {if (Push) {Push.setRegistrationID(userID, () => {console.log('setRegistrationID ok', userID);Push.registerPush(SDKAppID, appKey, (data) => {console.log('registerPush ok', data);Push.getRegistrationID((registrationID) => {console.log('getRegistrationID ok', registrationID);});}, (errCode, errMsg) => {console.error('registerPush failed', errCode, errMsg);});});// 监听通知栏点击事件,获取推送扩展信息Push.addPushListener(Push.EVENT.NOTIFICATION_CLICKED, (res) => {console.log('notification clicked', res);// 解析扩展信息,跳转到相应的会话(代码仅供参考,发布前需要完善)try {const data = JSON.parse(res.data);const conv_type = data?.entity?.chatType === 1 ? 'C2C' : 'GROUP';// 根据推送信息拼的 conversationIDconst conversationID = `${conv_type}${data.entity.sender}`;// 切换会话TUIConversationService.switchConversation(conversationID);const chatPath = '/TUIKit/components/TUIChat/index';uni.navigateTo({ url: chatPath });} catch (error) {console.log('error', error);}});// 监听在线推送Push.addPushListener(Push.EVENT.MESSAGE_RECEIVED, (res) => {// res 为消息内容console.log('message received', res);});// 监听在线推送被撤回Push.addPushListener(Push.EVENT.MESSAGE_REVOKED, (res) => {// res 为被撤回的消息 IDconsole.log('message revoked', res);});}});
本页内容是否解决了您的问题?