This article covers the process of enabling Huawei push notifications for an app that is already registered with the edna Pulse. Such apps have the Connected status that you can see in the push channel window. If you have not registered the app yet, refer to this article for the process of enabling Huawei push notifications for a new app.
You enable Huawei push notifications for a registered push channel on the Channels page.
Before you continue with the setup, verify that you have the following:
• An Android app with minSdk no earlier than 21 (Android 5) and targetSdk no later than 33 (Android 13)
• The Huawei App ID and Huawei App Secret parameters from Huawei AppGallery
• The agconnect-services.json file from Huawei AppGallery
• A current version of Android Studio
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, refer to this article.
- Click Connect.
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.