2

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.

Faizan Ahmad
  • 352
  • 4
  • 20

2 Answers2

1

Could you pls check if the onNewToken method returns a token? To better locate this issue, Can you mind share the APK from AppGallery and detailed logcat logs for us to check? You could send the APK to hmscore@huawei.com.

ttljtw
  • 51
  • 4
  • I checked it, I am unable to get token in onNewToken method too. Please check your email, I had sent you app link and logs' file. – Faizan Ahmad Dec 07 '21 at 05:26
  • I found 6003 in the log file you provided, which indicates that the SHA256 value configured on the AGC is inconsistent with that of the installation package. I checked that the sha256 of your installation package is AF:E5:9A:A8:F0:B2:9A:FA:45:51:55:E2:AB:8B:34:F9:5C:B7:49:E6:E7:61:EC:F5:24:0F:67:DB:E9:10:84:41. Please check the [configuration](https://developer.huawei.com/consumer/en/doc/development/HMSCore-Guides/android-config-agc-0000001050170137#section1159841225116) on the AGC. – ttljtw Dec 09 '21 at 02:04
  • Yes I resolved it. Thanks a lot for your response. – Faizan Ahmad Dec 09 '21 at 08:15
1

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.

Faizan Ahmad
  • 352
  • 4
  • 20