Huawei Flutter SDK Setup

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

Requirements

  • Android Studio
  • A Huawei device with "Huawei App Gallery" installed
  • Configured OneSignal App and Platform

Configure your OneSignal App and Platform

Details on configuring your OneSignal App and Platform (click to expand)

If you haven't already, sign up for a free account on onesignal.com.

You can setup multiple platforms (iOS, Android, Web, Email, SMS) within the same OneSignal App under Settings > Platforms. If you want to create a new app select New App/Website. If this is your first OneSignal app, you will see the next page.



Name your app and organization something recognizable, then select the platform to setup. You can always set up more platforms in this OneSignal App later within Settings > Platforms.

Click Next: Configure Your Platform.


To configure your app, follow the prompts based on the platforms you support.

After you setup your credentials, click Save & Continue.

Choose your Apps Target SDK, the click Save & Continue.


Finally, you will be directed to install the SDK and provided your OneSignal App ID. Make sure to save your App ID as you will need it later.

If you need a teammate or your developer to assist, you can click Invite them to the app and select Done when finished.


Continue through the documentation to finish adding OneSignal to your app.

Setup

1. Setup the OneSignal Flutter SDK

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

2. Huawei Setup

Configure App Information in AppGallery Connect
See Huawei's Configure App Information in AppGallery Connect

Add dependencies to Flutter android project
Under project build.gradle add the following

🚧

Huawei Flutter Plugin

If using Flutter Huawei Plugin Skip to step 3

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

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

allprojects {
    repositories {
        google()
        maven { url 'http://developer.huawei.com/repo/' }
    }
}
  • Under app build.gradle add the following
dependencies {
    ...
    implementation 'com.huawei.hms:push:6.3.0.304'
}

apply plugin: 'com.huawei.agconnect'

3. Flutter Huawei Plugin setup (Optional)

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

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

4. Huawei Location Service (Optional)

Add implementation 'com.huawei.hms:location:<HUAWEI HMS VERSION #> to your app build.gradle's dependencies section.

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 Flutter project integrating the Huawei Flutter 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.