Enable push notifications in an Android app (Huawei)
This guide walks you through enabling push notifications in your Android app using Huawei Mobile Services (HMS) and the Acoustic Connect SDK. HMS is required to reach users on Huawei devices that do not have Google Play Services.
Languages: Kotlin and Java
Availability: Pro, Premium, and Ultimate
Scope: This guide covers setting up push notifications for development and testing. For production configuration, see Prepare the Connect library for production use.
Prerequisites
- Connect SDK 11.0.11 or later, integrated into your app. See the integration guide for your architecture: View-based or Jetpack Compose. If you are upgrading from SDK 10.x, see Update the Connect Android library.
- Your project meets the prerequisites for Huawei HMS Core integration.
NoteThis guide assumes you have already set up FCM push notifications in your app. If you are not planning to use Firebase, complete the SDK push configuration and notification permission steps in Enable push notifications in an Android app (Firebase) before returning here.
Overview
- You — set up Huawei Mobile Services in your project
- You — share your HMS credentials with your Connect administrator
- You — update your Gradle configuration
- You — update the push configuration in the SDK initialization code
- Connect administrator — adds the HMS credentials to your Mobile app integration in Connect
Steps 3–4 can be completed while waiting for your Connect administrator to complete Step 5. Push notifications will not be delivered until Step 5 is done.
Step 1: Set up Huawei Mobile Services
- Create an app in AppGallery Connect.
- Enable Push Kit.
- Generate your SHA-256 signing certificate fingerprint and register it in AppGallery Connect under General information > SHA-256 certificate fingerprint. To get the debug fingerprint, run:
keytool -list -v \
-keystore ~/.android/debug.keystore \
-alias androiddebugkey \
-storepass android \
-keypass android- Download the configuration file (agconnect-services.json) from your project settings and place it in your app's
app/directory. Re-download the file after registering the fingerprint — it must reflect the updated configuration.
Step 2: Share HMS credentials with your Connect administrator
Copy the following values from agconnect-services.json and share them with your Connect administrator so they can add the HMS credentials to your Mobile app integration in Connect. Your app key will stay the same.
- HMS client ID
- HMS project ID
- HMS application ID
- HMS client secret
Step 3: Update your Gradle configuration
Replace the connect-push-fcm entry in your dependencies with connect-push. This artifact bundles both FCM and HMS support and auto-detects the available provider on the device — HMS on Huawei devices, FCM on standard Android devices. You do not need to declare :connect, :connect-push-fcm, or :connect-push-hms separately.
If you are building exclusively for AppGallery with no Firebase dependency, use connect-push-hms instead.
In settings.gradle, add the Huawei repository to both pluginManagement and dependencyResolutionManagement:
pluginManagement {
repositories {
google()
mavenCentral()
gradlePluginPortal()
maven { url 'https://developer.huawei.com/repo/' }
}
}
dependencyResolutionManagement {
repositories {
google()
mavenCentral()
maven { url 'https://developer.huawei.com/repo/' }
}
}In the root build.gradle file:
plugins {
id 'com.android.application' version '8.4.0' apply false
id 'org.jetbrains.kotlin.android' version '1.9.22' apply false
id 'com.huawei.agconnect' version '1.9.1.304' apply false
}
buildscript {
repositories {
maven { url 'https://developer.huawei.com/repo/' }
}
dependencies {
classpath 'com.huawei.agconnect:agcp:1.9.1.304'
}
}In the app-level build.gradle file:
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'com.huawei.agconnect'
}
dependencies {
implementation "io.github.go-acoustic:connect-push:11.0.11"
// For AppGallery-only builds: implementation "io.github.go-acoustic:connect-push-hms:11.0.11"
}For a working example, see app/build.gradle.kts in the sample app for your architecture:
- View-based: app/build.gradle.kts
- Jetpack Compose: app/build.gradle.kts
Add ConnectPushConfig to your existing SDK initialization call, or update it if you already have one from the Firebase setup. Remove strictProvider if present so the SDK auto-detects the best available provider — HMS on Huawei devices, FCM on standard Android devices.
ConnectPushConfig(
application = this,
iconRes = R.drawable.ic_notification,
onTokenReady = { token -> },
onFailure = { exception -> },
onPermissionResult = { isGranted -> }
)ConnectPushConfig(
application = application,
iconRes = R.drawable.ic_notification,
onTokenReady = { token -> },
onFailure = { exception -> },
onPermissionResult = { isGranted -> }
)The iconRes parameter is the same one you set up for FCM — it appears on the left side of the notification and in the status bar regardless of which push provider delivers it.
For a working example, see MainActivity.kt in the sample app for your architecture:
- View-based: MainActivity.kt
- Jetpack Compose: MainActivity.kt
NoteOn devices where both HMS and FCM are available, HMS takes priority. To force FCM on such devices, set
strictProvider = MobileServiceType.FCMinConnectPushConfig.
Try the sample app
Two reference implementations are available, one for each architecture:
- View-based: Acoustic Connect Mobile Push Sample App for Android (XML)
- Jetpack Compose: Acoustic Connect Mobile Push Sample App for Android (Compose)
Troubleshooting
| Symptom | Cause | Fix |
|---|---|---|
907135700: get scope error | Push Kit not enabled in AppGallery Connect | Enable Push Kit: My apps → Develop → APIs enabled |
907135702: certificate fingerprint empty | SHA-256 fingerprint not registered in AppGallery Connect | Add the fingerprint, then re-download agconnect-services.json and replace the file in app/ |
| Push token never arrives | Notification permission denied on Android 13+ | Grant POST_NOTIFICATIONS permission when prompted, or direct the user to app notification settings |
Testing
Testing push notifications requires a physical Huawei device — the Android emulator does not support HMS delivery.
- Connect a physical Huawei device to your computer via USB (or Wi-Fi) and run the app from Android Studio. The device must have an active internet connection.
- Grant notification permission when prompted.
- Verify that a push token is received via the
onTokenReadycallback inConnectPushConfig. - Coordinate with your marketing team to send a test push to your device.
- Verify the notification appears, images load, and push signals appear in the contact's activity feed in Connect.
Next steps
Push setup is now complete. To make the most of push notifications, try this:
- Identify users at sign-in — send a logged in signal after authentication so Connect can match the app visitor to a known contact.
- Identify users at registration — send an account registered signal after sign-up to create or match a contact from their first session.
- Prepare for production — configure separate HMS projects for dev and production and get your app ready to ship.
Updated 2 days ago
