2

I'm trying to use Huawei push kit and after updating the HMS following error was thrown when trying to send upstream data.

Some configs:

  • Device: Samsung Galaxy A40 + HMS Core installed 5.0.2.301

Libraries:

  • implementation("com.huawei.hms:push:5.0.2.300")
  • implementation("com.huawei.agconnect:agconnect-core:1.4.1.300")

AGConnect: classpath 'com.huawei.agconnect:agcp:1.4.1.300'

Calling the code:

val messaging = HmsMessaging.getInstance(this.applicationContext)
messaging.send(
  RemoteMessage.Builder("push.hcm.upstream")
    .setMessageId("Message#${System.currentTimeMillis()}")
    .setData(data)
    .build()
)

Causes this error:

java.lang.UnsupportedOperationException: push kit initializing, try again later
        at com.huawei.hms.push.HmsMessaging.a(HmsMessaging.java:212)
        at com.huawei.hms.push.HmsMessaging.send(HmsMessaging.java:204)
        at ir.malv.plusdependencytest.MainActivity$initializeListStuff$1$15.invoke(MainActivity.kt:355) // related to the code I called
        at ir.malv.plusdependencytest.MainActivity$initializeListStuff$1$15.invoke(MainActivity.kt:43)
        at ir.malv.plusdependencytest.UtilsKt$input$2.onClick(Utils.kt:47)
        at androidx.appcompat.app.AlertController$ButtonHandler.handleMessage(AlertController.java:167)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:237)
        at android.app.ActivityThread.main(ActivityThread.java:7948)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1075)

And it just remains "initializing".

Note that the library used to work with a previous version of HMS core, so neither Phone or Process of Push on no-Huawei can be the reason.

Mahdi-Malv
  • 16,677
  • 10
  • 70
  • 117
  • Please provide detailed logs, only one error message is not enough. 1. Does the error was thrown occasionally ot inevitably? 2. Does the code have automatic initialization configuration? 3. Can you obtain the token? – zhangxaochen Sep 14 '20 at 03:31
  • @shirley Thanks for the response. With further testing I realized that issue was resolved using a lower version of **HMS** (5.0.0.304). -- However in the latest version the error occurs **all the time** and there is not specific condition. And the **`auto_init` is enabled** using **manifest config**. – Mahdi-Malv Sep 14 '20 at 08:05
  • Can you obtain the token by using automatic initialization capability of the HMS Core Push SDK? We are trying to fix the problem, but failed to apply for tokens. – zhangxaochen Sep 15 '20 at 01:56
  • I'm afraid not. The code `getToken` using `HmsInstanceId` just **awaits** and does not reach the return of token. Also, no token is sent to `onNewToken` of `HmsMessaging` either. – Mahdi-Malv Sep 15 '20 at 07:24
  • Could you please provide a complete log file, from obtaining the token to uplink message sending. We will find the reason why the token fails to be obtained. – zhangxaochen Sep 16 '20 at 01:39
  • Stucking at push kit initializing is probably related to the token failed to be obtained. Please add the logcat in the question or send an email to hmscore@huawei.com for further analyse. :) – zhangxaochen Sep 16 '20 at 09:44
  • I'll send the full log as soon as I updated the HMS core again. – Mahdi-Malv Sep 16 '20 at 11:18
  • 1
    @shirley I updated the HMS core again. The issue seems to be resolved and token is obtained. Any idea what could have happened? – Mahdi-Malv Sep 16 '20 at 11:52
  • I noticed that your Huawei phone cannot obtain the token in your [latest question](https://stackoverflow.com/q/63918878/13329100) while your no-Huawei can obtain the token. Better provide the log (Samsung G-A40)(from obtaining the token to uplink message sending) for us to analyze the reason. :) – zhangxaochen Sep 17 '20 at 06:50
  • @shirley Sure. Will update that question with A40 logs as well. – Mahdi-Malv Sep 17 '20 at 09:58

1 Answers1

0

Issue seems to be because of IP-restriction and resolved after latest version of Hms-Core.

Mahdi-Malv
  • 16,677
  • 10
  • 70
  • 117