Search code examples
androidhuawei-mobile-serviceshuawei-developershuawei-push-notification

Huawei push kit: stuck at push kit initializing, try again later


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.


Solution

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