1

I've build an app using Ionic 5 (Angular) and Capacitor. I'm using the Capacitor plugin for Push Notifications. All is working fine on both iOS and Android. However on Huawai phones (P30 and later) things don't work properly.

No device id is obtained and Push Notifications don't work, even the PushNotifications.addListener('registration', async (token: PushNotificationToken) => {}) is not triggered.

Any ideas on what I need to do so that I can maintain one codebase and make it work on both Android "worlds" (Google & Huawei) ?

Thanks in advance, Chris

chrisvor
  • 41
  • 11

1 Answers1

1

Probably the Ionic plug-ins you used are provided for GMS and Firebase so that their capabilities can be directly called in Ionic. Therefore, apps developed by Ionic must directly call HMS capabilities when Google Play services are unavailable.

You are advised to use HMS Ionic plugin to integrate HMS Push Kit in Ionic App. You can get the Push Plugin from here. Please use 5.0.0 version.

Or you can get it from npmjs here.

Update:

If you look for a way which allows you to use both push notifications in the same application by detecting the device type and acting accordingly, you can use G+H solution. Using the G+H approach, you are able to maintain one codebase and decide whether to use GMS or HMS based on the availability of either one.

From: https://stackoverflow.com/a/63337530/13329100

zhangxaochen
  • 32,744
  • 15
  • 77
  • 108
  • Thank you for your reply. I'm using the Capacitor built-in plugin for push notifications. It's using FCM on the background. Does this work with HMS? If not and I use the HMS Ionic plugin, can they co-exist? How do I detect that I should use the HMS plugin or the Capacitor one at run-time? Or should I create two versions, one for Google Play and one for Huawei App Gallery? (I'd hate to maintain and/or publish two different versions... I picked Ionic for cross-platform development with a single source... What an irony to have to maintain two versions for Android-only devices......) – chrisvor Sep 30 '20 at 19:20
  • @chrisvor If you look for a way which allows you to use both push notifications in the same application by detecting the device type and acting accordingly, you can use G+H solution. Using the G+H approach, you are able to maintain one codebase and decide whether to use GMS or HMS based on the availability of either one. – zhangxaochen Oct 14 '20 at 01:33