react-native-tim-push
package, execute the following code in the terminal.# use yarn
yarn
add
react-native-tim-push
# use npm
npm
install
react-native-tim-push
TimPushPlugin.getInstance().setApnsCertificateID
method to pass in the certificate ID.import { TimPushPlugin } from 'react-native-tim-push';const certificateID = 'certificate id';TimPushPlugin.getInstance().setApnsCertificateID(certificateID);
android/app/src/main/assets
directory. If the directory does not exist, please create it manually.1. Choose to download the configuration file timpush-configs.json | 1. Add to the project |
| |
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);}}
...#import <Your-Project-Name-Swift.h>// My project Name is `TimPushExample`. So it should be `#import <TimPushExample-Swift.h>`...
- (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;}
dependencies { // Huaweiimplementation 'com.tencent.timpush:huawei:${Push Plugin version number}'// XiaoMiimplementation 'com.tencent.timpush:xiaomi:${Push Plugin version number}'// vivoimplementation 'com.tencent.timpush:vivo:${Push Plugin version number}'// Honorimplementation 'com.tencent.timpush:honor:${Push Plugin version number}'// Meizuimplementation 'com.tencent.timpush:meizu:${Push Plugin version number}'// Google Firebase Cloud Messaging (Google FCM)implementation 'com.tencent.timpush:fcm:${Push Plugin version number}'// Choose one of the two below for OPPO// For the China Region, choose to integrate this packageimplementation 'com.tencent.timpush:oppo:${Push Plugin version number}'// For other regions, choose to integrate this packageimplementation 'com.tencent.timpush:oppo-intl:${Push Plugin version number}' }
// android/app/build.gradleandroid {...defaultConfig {...manifestPlaceholders = ["VIVO_APPKEY" : "`APPKEY` of the certificate assigned to your application","VIVO_APPID" : "`APPID` of the certificate assigned to your application","HONOR_APPID" : "`APPID` of the certificate assigned to your application"]}}
// android/app/src/main/AndroidManifest.xml// Vivo begin<meta-data tools:replace="android:value"android:name="com.vivo.push.api_key"android:value="`APPKEY` of the certificate assigned to your application" /><meta-data tools:replace="android:value"android:name="com.vivo.push.app_id"android:value="`APPID` of the certificate assigned to your application" />// Vivo end// Honor begin<meta-data tools:replace="android:value"android:name="com.hihonor.push.app_id"android:value="`APPID` of the certificate assigned to your application" />// Honor end
buildscript {dependencies {...classpath 'com.google.gms:google-services:4.3.15'classpath 'com.huawei.agconnect:agcp:1.4.1.300'classpath 'com.hihonor.mcs:asplugin:2.0.1.300'}}
pluginManagement {repositories {gradlePluginPortal() mavenCentral() maven { url "https://mirrors.tencent.com/nexus/repository/maven-public/" } // Configure the Maven repository address for HMS Core SDK. maven {url 'https://developer.huawei.com/repo/'} maven {url 'https://developer.hihonor.com/repo'}}}dependencyResolutionManagement {...repositories {mavenCentral() maven { url "https://mirrors.tencent.com/nexus/repository/maven-public/" } // Configure the Maven repository address for HMS Core SDK. maven {url 'https://developer.huawei.com/repo/'} maven {url 'https://developer.hihonor.com/repo'}}}}
buildscript {repositories {mavenCentral() maven { url "https://mirrors.tencent.com/nexus/repository/maven-public/" } // Configure the Maven repository address for HMS Core SDK. maven {url 'https://developer.huawei.com/repo/'} maven {url 'https://developer.hihonor.com/repo'}}dependencies {...classpath 'com.google.gms:google-services:4.3.15'classpath 'com.huawei.agconnect:agcp:1.4.1.300'classpath 'com.hihonor.mcs:asplugin:2.0.1.300'}}
dependencyResolutionManagement {...repositories {mavenCentral() maven { url "https://mirrors.tencent.com/nexus/repository/maven-public/" } // Configure the Maven repository address for HMS Core SDK. maven {url 'https://developer.huawei.com/repo/'} maven {url 'https://developer.hihonor.com/repo'}}}
buildscript {repositories {mavenCentral() maven { url "https://mirrors.tencent.com/nexus/repository/maven-public/" } // Configure the Maven repository address for HMS Core SDK. maven {url 'https://developer.huawei.com/repo/'} maven {url 'https://developer.hihonor.com/repo'}}dependencies {...classpath 'com.google.gms:google-services:4.3.15'classpath 'com.huawei.agconnect:agcp:1.4.1.300'classpath 'com.hihonor.mcs:asplugin:2.0.1.300'}}allprojects {repositories {mavenCentral() maven { url "https://mirrors.tencent.com/nexus/repository/maven-public/" } // Configure the Maven repository address for HMS Core SDK. maven {url 'https://developer.huawei.com/repo/'} maven {url 'https://developer.hihonor.com/repo'}}}
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
method, passing in a callback function defined for clicks.apnsCertificateID
for the iOS push certificate ID and androidPushOEMConfig
for the Android push vendor configuration. These two configurations should have been specified in previous steps, and if no modification is necessary, they do not need to be passed again.TimPushPlugin.getInstance().registerPush({onNotificationClicked: (extString) => {},})
TimPushPlugin.getInstance().registerOnNotificationClickedEvent
method as soon as possible to manually mount the message click callback, so that you can promptly obtain the message parameters.TimPushPlugin.getInstance().registerPush
and place it as early as possible in the code.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
Callback Address Configuration | Receipt ID Configuration in the IM Console |
Receipt Address: https://api.im.qcloud.com/v3/offline_push_report/vivo | |
Enable Receipt Switch | Configure Receipt Address |
| |
https://api.im.qcloud.com/v3/offline_push_report/meizu
Was this page helpful?