Search code examples
notificationshuawei-mobile-serviceshuawei-developershuawei-push-notificationappgallery-connect

HMS getToken returns null if app is installed from APPGALLERY


I build an app. I am using the HMS Push kit for notifications. It is working fine if I build apk and install it on a device directly. But if I install this app from Huawei AppGallery, it returns a null token to me. To get Token I wrote this code:

       String appId = AGConnectServicesConfig.fromContext(context).getString("client/app_id");
       String token = HmsInstanceId.getInstance(context).getToken(appId, "HCM");

I do not know what is the problem with installing an app from AppGallery. I cross verified SHA-256 key, connect-services.json file, appid etc. The app will work fine if I make debug or release apk and install it on a device. The app will return a null token if I will install it from AppGallery.


Solution

  • Huawei is generating 2 SHA-256 keys, one locally. Second at App Signing module at developer account. After adding second SHA-256 key, my issue was resolved.