Requirements

  • Huawei Developer Account.

  • Huawei mobile app.

  • PushBots account.

  • Android studio 2.3+

  • [optional] Huawei 2020 model or newer to test with.

Step 1: Get HMS credentials:

1. Open AppGallery connect dashboard.

2. Create new Project:

And enter project name:

Click on Add app, Enter package then fill details and click ok:

Copy appId, and clientId to be used inside the applicaiton:

Generate SHA-256 key and add it in app settings:

  • From Android Studio open View > Tool Windows > Gradle

  • select app > Tasks > android > signingReport

  • Copy your SHA-256 for your release variant.

Step 2: Enable Push kit:

Click on Push kit then click on Enable now

Step 4: Add Huawei Gradle Plugin and Dependencies

build.gradle (project)

allprojects { repositories { maven { url 'http://developer.huawei.com/repo/' } } }

Step 5: Import the PushBots library into your project:

Follow instructions in this link:

https://www.pushbots.help/en/articles/498214-the-pushbots-part-integrating-pushbots-sdk-into-your-android-project

Open build.gradle (Module: app) file:

1. Comment firebases-messaging dependency:

//implementation 'com.google.firebase:firebase-messaging:20.2.4'

2. Add HMS push kit dependency, and make sure you're using pushbots-lib 3.3.5-beta2+ for HMS support:

implementation 'com.pushbots:pushbots-lib:3.3.5-beta2@aar'
implementation 'com.huawei.hms:push:5.0.0.300'

3. Replace senderid with HMS clientId:

new Pushbots.Builder(this)
.setLogLevel(Pushbots.LOG_LEVEL.DEBUG)
.setPushbotsAppId("5df0d5c74a6d71055f2ede44")
.setSenderId("HMS_CLIENT_ID")
.build();

4. Add HMS appid in manifest file inside <application tag:

<meta-data
android:name="com.huawei.hms.client.appid"
android:value="appid=HMS-APPID" />

Compile the application to release in appgallaery.

Did this answer your question?