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

📘

Note

This 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

  1. You — set up Huawei Mobile Services in your project
  2. You — share your HMS credentials with your Connect administrator
  3. You — update your Gradle configuration
  4. You — update the push configuration in the SDK initialization code
  5. 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

  1. Create an app in AppGallery Connect.
  2. Enable Push Kit.
  3. 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
  1. 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:

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:

📘

Note

On devices where both HMS and FCM are available, HMS takes priority. To force FCM on such devices, set strictProvider = MobileServiceType.FCM in ConnectPushConfig.

Try the sample app

Two reference implementations are available, one for each architecture:

Troubleshooting

SymptomCauseFix
907135700: get scope errorPush Kit not enabled in AppGallery ConnectEnable Push Kit: My appsDevelopAPIs enabled
907135702: certificate fingerprint emptySHA-256 fingerprint not registered in AppGallery ConnectAdd the fingerprint, then re-download agconnect-services.json and replace the file in app/
Push token never arrivesNotification 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.

  1. 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.
  2. Grant notification permission when prompted.
  3. Verify that a push token is received via the onTokenReady callback in ConnectPushConfig.
  4. Coordinate with your marketing team to send a test push to your device.
  5. 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.