When developing applications for the Android ecosystem, you may encounter Huawei or Honor devices that either lack Google Mobile Services (GMS) entirely or have both GMS and Huawei Mobile Services (HMS) installed simultaneously.
This article explains how the Pushwoosh SDK determines which gateway to use for push notification delivery, which tokens are returned, and how it handles dynamic changes to installed services.
1. Gateway Prioritization: HMS vs. FCM
If a device has both GMS (Google Play Services) and HMS installed, FCM always takes priority.
The Pushwoosh SDK contains explicit logic that prioritizes Google Services. If GoogleApiAvailability reports that GMS is available, the SDK treats the device as a standard Android device and routes push notifications through FCM, even if the pushwoosh-huawei module is integrated into the app.
When does the SDK use HMS? The SDK will only use the Huawei gateway if all three of the following conditions are met:
- It is a Huawei/Honor device.
- GMS (Google Play Services) is not available on the device (a "pure" Huawei device).
- The
pushwoosh-huaweimodule has been successfully integrated into your application.
Note: While it is technically possible to manually install HMS on non-Huawei Android devices, they will not function correctly with the Huawei push gateway. Pushwoosh will always route pushes via FCM for non-Huawei devices.
2. Which push token is returned by getPushToken()?
When you call Pushwoosh.getInstance().getPushToken(), the returned token depends on the active gateway determined during SDK initialization:
- FCM Token: Returned if the device has GMS installed (prioritized), or if GMS is missing but the
pushwoosh-huaweimodule was not integrated. - HMS Token: Returned only if the device is a Huawei device without GMS, and the
pushwoosh-huaweimodule is integrated.
If you send a push notification to this device, the Pushwoosh backend will automatically deliver it through the gateway that corresponds to the registered token.
3. Dynamic Changes (Adding or Removing Services)
The Pushwoosh SDK evaluates which push service to use at every cold start of the application. It does not cache the chosen gateway persistently across sessions.
Because of this, the SDK automatically adapts if the device's service environment changes (e.g., if a user roots their Huawei device and manually uninstalls or installs Google Services). You do not need to clear the app data for the changes to take effect.
Here is how the SDK behaves during specific service changes upon the next app cold start:
- GMS is removed from an HMS-active device: The SDK was using HMS, and GMS was removed. Nothing changes; the app will continue to use HMS.
- HMS is removed from an HMS-active device: The SDK will re-evaluate, determine it is no longer a valid Huawei push environment, and will automatically switch and register via FCM.
- GMS is removed from an FCM-active device (with Huawei module): If the app has the
pushwoosh-huaweimodule, the SDK will see GMS is gone and will automatically switch and register via HMS. - HMS is removed from an FCM-active device: The SDK was using FCM, and HMS was removed. Nothing changes; the app will continue to use FCM.
Comments
0 comments
Please sign in to leave a comment.