//
yarn
yarn
add
react-native-tim-push
//
npm
npm
install
react-native-tim-push
TimPushPlugin.getInstance().setApnsCertificateID
方法, 将此证书 ID 传入。import { TimPushPlugin } from 'react-native-tim-push';const certificateID = '证书ID';TimPushPlugin.getInstance().setApnsCertificateID(certificateID);
android/app/src/main/assets
目录下,如果该目录不存在,请手动创建。1.选择下载配置文件 timpush-configs.json | 2.添加到工程 |
| |
TencentIMPush.swift
文件并将以下的代码复制进去:import Foundationimport react_native_tim_push@objc class TencentImPush: NSObject{@objc func getOfflinePushCertificatedID() -> Int32 {return TencentCloudPushModal.shared.offlinePushCertificateID();}@objc func getApplicationGroupID() -> String {return TencentCloudPushModal.shared.applicationGroupID();}@objc func onRemoteNotificationReceived(_ notice: String?) -> Void {TencentCloudPushModal.shared.onRemoteNotificationReceived(notice);}}
AppDelegate.h
文件并在该文件中添加如下代码:...#import <Your-Project-Name-Swift.h>// My project Name is `TimPushExample`. So it should be `#import <TimPushExample-Swift.h>`...
AppDelegate.mm
文件并在该文件中添加如下代码:- (int)offlinePushCertificateID {TencentImPush *instance = [[TencentImPush alloc] init];return [instance getOfflinePushCertificatedID];}- (NSString *)applicationGroupID {TencentImPush *instance = [[TencentImPush alloc] init];return [instance getApplicationGroupID];}- (BOOL)onRemoteNotificationReceived:(NSString *)notice {TencentImPush *instance = [[TencentImPush alloc] init];[instance onRemoteNotificationReceived:notice];return YES;}
MainApplication.java
中引入com.timpush.RNTencentIMPushApplication
,并将Application
替换成RNTencentIMPushApplication
。如下图所示:dependencies { // Huaweiimplementation 'com.tencent.timpush:huawei:${推送插件的版本号}'// XiaoMiimplementation 'com.tencent.timpush:xiaomi:${推送插件的版本号}'// vivoimplementation 'com.tencent.timpush:vivo:${推送插件的版本号}'// Honorimplementation 'com.tencent.timpush:honor:${推送插件的版本号}'// Meizuimplementation 'com.tencent.timpush:meizu:${推送插件的版本号}'// Google Firebase Cloud Messaging (Google FCM)implementation 'com.tencent.timpush:fcm:${推送插件的版本号}'//OPPO 以下二选一//中国区域选择集成此包implementation 'com.tencent.timpush:oppo:${推送插件的版本号}'//其他区域选择集成此包implementation 'com.tencent.timpush:oppo-intl:${推送插件的版本号}' }
// android/app/build.gradleandroid {...defaultConfig {...manifestPlaceholders = ["VIVO_APPKEY" : "您应用分配的证书 APPKEY","VIVO_APPID" : "您应用分配的证书 APPID","HONOR_APPID" : "您应用分配的证书 APPID"]}}
// android/app/src/main/AndroidManifest.xml// Vivo begin<meta-data tools:replace="android:value"android:name="com.vivo.push.api_key"android:value="您应用分配的证书 APPKEY" /><meta-data tools:replace="android:value"android:name="com.vivo.push.app_id"android:value="您应用分配的证书 APPID" />// Vivo end// Honor begin<meta-data tools:replace="android:value"android:name="com.hihonor.push.app_id"android:value="您应用分配的证书 APPID" />// Honor end
buildscript {repositories {mavenCentral() maven { url "https://mirrors.tencent.com/nexus/repository/maven-public/" } // 配置HMS Core SDK的Maven仓地址。 maven {url 'https://developer.huawei.com/repo/'} maven {url 'https://developer.hihonor.com/repo'}}dependencies {...classpath 'com.google.gms:google-services:4.2.0'classpath 'com.huawei.agconnect:agcp:1.4.1.300'classpath 'com.hihonor.mcs:asplugin:2.0.1.300'}}
apply plugin: 'com.google.gms.google-services'apply plugin: 'com.huawei.agconnect'apply plugin: 'com.hihonor.mcs.asplugin'
(ext: string, userID?: string, groupID?: string): void;
的入参形式。TimPushPlugin.getInstance().registerPush
方法, 需传入上一步定义的点击回调函数。apnsCertificateID
iOS 推送证书 ID 及 androidPushOEMConfig
Android 推送厂商配置。此二项配置已在前序步骤指定,若无修改必要,可不再传入。TimPushPlugin.getInstance().registerPush({onNotificationClicked: (extString) => {},})
TimPushPlugin.getInstance().registerOnNotificationClickedEvent
方法,手动挂载消息单击回调,以便及时获取消息参数。TimPushPlugin.getInstance().registerPush
之前执行此函数,并尽可能提前将其放置在代码中。TimPushPlugin
.
getInstance
(
)
.
registerOnNotificationClickedEvent
({onNotificationClicked: _onNotificationClicked});
https://api.im.qcloud.com/v3/offline_push_report/huawei
https://api.im.qcloud.com/v3/offline_push_report/honor
回调地址配置 | 回执 ID 配置 IM 控制台 |
回执地址: https://api.im.qcloud.com/v3/offline_push_report/vivo | |
打开回执开关 | 配置回执地址 |
| |
https://api.im.qcloud.com/v3/offline_push_report/meizu
本页内容是否解决了您的问题?