This article covers the process of enabling Huawei push notifications for an application that is already registered with the edna Pulse. Such applications have the Connected status that you can see in the push channel window.
If you haven’t registered the application yet, follow the instructions on how to enable push notifications for Android.
Make sure you have:
- Android app with minSdk no earlier than 21 (Android 5) and targetSdk no later than 33 (Android 13);
- Huawei App ID and Huawei App Secret parameters from Huawei AppGallery;
- agconnect-services.json file from Huawei AppGallery;
- current version of Android Studio.
Step 1. Enter App Data from Huawei
- On the Settings → Channels page in the edna Pulse, select the push channel for which you want to enable Huawei Cloud and click Edit.
- Scroll down and click Connect in the Huawei App section.
- In the respective fields, enter the Huawei App ID and Huawei App Secret parameters obtained from Huawei AppGallery. If you haven’t registered the app in Huawei AppGallery, read the article.
- Click Connect.
Step 2. Update Dependencies in build.gradle File
- Update dependencies in the project’s build.gradle file — add Huawei services to the list of the dependencies.
buildscript { repositories { //... maven { url 'http://developer.huawei.com/repo/' } } //... dependencies { //... classpath "com.google.gms:google-services:4.3.10" classpath "com.huawei.agconnect:agcp:1.6.0.300" } //... allprojects { repositories { //... maven { url 'https://maven-pub.edna.ru/repository/maven-public'} maven { url 'http://developer.huawei.com/repo/' } } }
- To the build.gradle file of the app, apply the plugin and add edna libraries to the list of dependencies.
apply plugin: 'com.huawei.agconnect' dependencies { //... implementation platform("com.edna.android:push-x-bom:2.0.0") implementation "com.edna.android:push-lite-huawei-release" }
- Add the following rules to the proguard-rules.pro file:
-keep class com.edna.android.push_lite.**{*;} -keep class com.hianalytics.android.**{*;} -keep class com.huawei.updatesdk.**{*;} -keep class com.huawei.hms.**{*;}
- To the root folder of your app, add the agconnect-services.json file you obtained in Huawei AppGallery.
All done! You can now send push notifications to your app via Huawei Cloud.