Integrate Huawei in React Native

How to integrate Huawei Push Notifications into your React Native project

Download Sample Module API Docs

1. Integrate the React Native Plugin

Refer to the React Native integration guide.

2. Configure Huawei via AppGallery Connect

2.1. Go to AppGallery Connect -> Projects List and select a project to configure.

2.2. Press agconnect-services.json in the App information section to download a configuration file.

2.3. Put the downloaded file into your Android Studio project (YOUR_PROJECT/app/agconnect-services.json).

3. Generate Signing Certificate Fingerprint

3.1. In Android Studio, go to View > Tool Windows > Gradle.

3.2. In the window opened, go to app > Tasks > android > signingReport.

3.3. Copy SHA-256 from your release keystore.

You can also add the SHA-256 from your debug keystore for testing purposes.

3.4. Select your project in AppGallery Connect Project List.

3.5. Paste the SHA-256 into the SHA-256 certificate fingerprint field.

Please be aware that fingerprint processing may take up to 10 minutes.

4. Configure Huawei in Pushwoosh

Follow the guide to configure the Huawei platform for your Pushwoosh project: Configure Huawei

5. Add dependencies

Add dependencies to your Android project:

  • To android/build.gradle

buildscript {
repositories {
google()
jcenter()
maven { url 'https://developer.huawei.com/repo/' }
}
dependencies {
...
classpath 'com.huawei.agconnect:agcp:1.4.1.300'
}
}
allprojects {
repositories {
...
google()
jcenter()
maven { url 'https://developer.huawei.com/repo/' }
}
}
  • To android/app/build.gradle

apply plugin: "com.huawei.agconnect"
...
dependencies {
...
implementation 'com.huawei.hms:push:5.0.2.300'
}

6. Enable push notifications

Import plugin and register for push notifications.

To enable Huawei Push Messaging in your React Native project you must call Pushwoosh.enableHuaweiPushNotifications(); when the application starts before calling Pushwoosh.register().

import Pushwoosh from 'pushwoosh-react-native-plugin';
Pushwoosh.init({
"pw_appid" : "YOUR_PUSHWOOSH_APP_ID" ,
"project_number" : "YOUR_FCM_SENDER_ID" // leave "YOUR_FCM_SENDER_ID" empty
}); // if you do not use Firebase
// Enables Huawei push notifications
Pushwoosh.enableHuaweiPushNotifications();
Pushwoosh.register();