Huawei phones (Push Kit)

Notifications on Huawei phones without Google services, with Huawei Push Kit and the REST API.

Recent Huawei phones (since 2019) don't have Google services, so they don't receive Firebase (FCM) notifications. To reach them, Pushtifly sends through Huawei Push Kit (HMS). Your app still registers with platform: "android"; only the token and the provider change.

1. Set up the app in AppGallery Connect

  1. Go to AppGallery Connect and open (or create) your project and the Android app with the same package name.
  2. Under Grow → Push Kit, click Enable now.
  3. Under Project settings → General, add the SHA-256 fingerprint of the certificate you sign the app with (without it, the phone won't issue a token).
  4. Download agconnect-services.json and copy it into your Android project's app/ folder.
  5. On the same page, under App information, copy the Client ID and the Client Secret (not the developer account's or the project's).

2. Save the credential in Pushtifly

In the app, under Credentials → Android on Huawei phones (Push Kit), click Add Huawei Push Kit, paste the Client ID and the Client Secret, and click Save.

Pushtifly requests an access token from Huawei and makes a validation send (nothing is delivered to any phone):

Result What it means
Valid credential You're all set.
Huawei rejected the Client ID or the Client Secret Check they're the ones from App information, copied in full.
The app doesn't have Push Kit enabled Enable Push Kit (step 1.2) and wait a few minutes.

The Client Secret is stored encrypted and is never shown again.

3. Get the token in the app

Add the Push Kit SDK (com.huawei.hms:push) and the AppGallery Connect plugin following Huawei's guide. You get the token with HmsInstanceId.getToken() (off the main thread), and it also arrives in HmsMessageService.onNewToken() when it changes.

class HuaweiPushService : HmsMessageService() {
    override fun onNewToken(token: String) = Pushtifly.registerHuawei(token)
}

// When the app opens, on a background thread
val appId = AGConnectOptionsBuilder().build(context).getString("client/app_id")
val token = HmsInstanceId.getInstance(context).getToken(appId, "HCM")
if (token.isNotEmpty()) Pushtifly.registerHuawei(token)

Does your app run on phones with and without Google? Check which services are available (GoogleApiAvailability or HuaweiApiAvailability) and register the token from whichever one is.

4. Register the device

A Huawei token can't be told apart from other tokens by its format, so mark it with provider: "hms":

curl -X POST https://api.pushtifly.com/v1/devices \
  -H "Authorization: Bearer pk_live_YOUR_PUBLIC_KEY" -H "Content-Type: application/json" \
  -d '{"token":"PUSH_KIT_TOKEN","platform":"android","provider":"hms","externalUserId":"user-123"}'

Without provider: "hms", Pushtifly would try to treat it as an FCM token and reject it (2002). If the app doesn't have a Huawei credential yet, the device stays in pending_credential and activates on its own once you save one.

The rest of the API works as on Android: identify, logout, tags, topics and events (opened, received).

5. What the phone receives

In Pushtifly In Huawei
Title, text and image notification (the image must be https)
data message.data (a JSON string); it reaches the app when the notification is tapped, along with _phid
https://… deepLink Opens that address
Another deepLink (or none) Opens the app; the link goes in the data
Buttons (up to 3) Push Kit buttons: with https they open the address; otherwise they open the app with {"actionId": …}
Android channel, color and tag channel_id, color and tag
Normal priority importance: NORMAL
ttl android.ttl (15 days maximum)

When the notification is tapped, read _phid from the Intent extras and report it to POST /v1/events with type: "opened", just like on Android.

Limits and errors

  • A message can't exceed 4 KB (not counting the token). If it does, the delivery fails with HMS_80300008.
  • Sends to Huawei can take a little longer than to FCM. If Huawei applies traffic control, Pushtifly retries on its own.
  • Errors you'll see in deliveries or in the test console:
Code What happened What to do
HMS_TOKEN_INVALID The token no longer works (app uninstalled or data cleared). The device is marked invalid. The app registers the new token when it opens.
HMS_OAUTH_ERROR, OAUTH_REJECTED Huawei rejected the Client ID or the Client Secret. Save them again in Credentials.
HMS_NO_PERMISSION Push Kit isn't enabled for the app. Enable it in AppGallery Connect.
HMS_CLIENT_NOT_FOUND The Client ID doesn't match any app. Copy the correct Client ID.
HMS_TRAFFIC_CONTROL Too many sends in a short time. Pushtifly retries; split large sends into waves.

Try it

In Tests, paste the token, choose Android Huawei (Push Kit) under "Pasted tokens belong to" and send. Validate without sending mode also works with Huawei.