Huawei React Native SDK Setup

Follow these instructions if your app is distributed on the Huawei AppGallery.

Step 1. Requirements

Step 2. Setup the OneSignal React Native SDK

Follow the OneSignal React Native SDK setup guide. Firebase / Google setup not required for app builds released to the Huawei AppGallery.

Step 3. Huawei Setup

3.1 Device and Android SDK Setup
3.2 Configure app information in AppGallery Connect
3.3 Integrating the HMS Core SDK
3.4 Add dependencies to React Native android project
In the case ReactNative plugin is going to be used (see step 4), then this step can be skipped.
Under project build.gradle add the following

buildscript {
    repositories {
        google()
        jcenter()
        maven { url 'https://developer.huawei.com/repo/' }
    }

    dependencies {
        ...
        classpath 'com.huawei.agconnect:agcp:1.6.0.300'
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        maven { url 'https://developer.huawei.com/repo/' }
    }
}
  • Under app build.gradle add the following
apply plugin: "com.android.application"
apply plugin: "com.huawei.agconnect"

...
  
dependencies {
    ...
    implementation 'com.huawei.hms:push:6.3.0.304'
}

Step 4. React Native Huawei Plugin setup (Optional)

OneSignal does not require the React Native Huawei plugin and in most cases you can omit this. However, if you need specific Huawei features in React Native see Integrating React Native HMS Push Kit Module

4.1 When following the plugin setup, after downloading the plugin remove the RNHmsMessageService from the downloaded plugin's AndroidManifest.xml file under the android package.

Step 5. Huawei Location Service (Optional)

5.1 Add implementation 'com.huawei.hms:location:<HUAWEI HMS VERSION #> to your app build.gradle's dependencies section.
5.2 Make sure to also add the location permission to your AndroidManifest.xml if you don't have this already

dependencies {
    ...
    implementation 'com.huawei.hms:location:4.0.0.300'
}

Notes/Resources

This is an example React Native project integrating the Huawei React Native Plugin.

  • HMS error code reference to help debug logs and successfully integrate HMS Core SDK with the OneSignal SDK.

Keystore Signature

  • Huawei Signing Certificate Usage
    • You may need to create a debug or release keystore signature (choose the correct app build path, debug or release) so that a 6003 error is avoided when registering for Huawei pushToken with the OneSignal SDK.