Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Huawei push kit: Token returns empty on Huawei phone

I recently tried my app on a Huawei phone.

The problem is PushKit does not return a token and getToken result is empty.

In the log I get GetTokenTask receive a empty token, please check HmsMessageService.onNewToken receive result., but there is not token given in onNewToken either.

Code to retrieve token:

GlobalScope.launch(context = Dispatchers.IO) {
    try {
        val appId = AGConnectServicesConfig.fromContext(this@MainActivity).getString("client/app_id")
        val token = HmsInstanceId.getInstance(this@MainActivity).getToken(appId, "HCM")
        Pulp.debug("Huawei", "Token received") {
            "token" to token
        }
    } catch (e: java.lang.Exception) {
        Pulp.error("Huawei", "Failed to fetch token", e) {
            "Cause" to (e.message ?: "Empty")
        }
    }
}

The result has not exception. But the token is empty (see last line of logs).

The code in the HMSService:

override fun onNewToken(token: String?) {
    super.onNewToken(token)
    Pulp.debug("Huawei", "(onNewToken): Huawei messaging token received") {
        "Token" to (token ?: "NO token")
    }
}

Full log from auto_init to the token request:

2020-09-16 15:33:50.791 19954-19954/ir.malv.plusdependencytest I/HMSSDK_AutoInit: Push init start
2020-09-16 15:33:50.854 19954-19954/ir.malv.plusdependencytest I/HMSSDK_HMSBIInitializer: Builder->biInitFlag :false
2020-09-16 15:33:50.856 19954-19954/ir.malv.plusdependencytest I/HMSSDK_HMSBIInitializer: Builder->biSetting :false
2020-09-16 15:33:50.859 19954-19954/ir.malv.plusdependencytest I/HMSSDK_CountryCodeBean: getCountryCode get country code from SIM_COUNTRY
2020-09-16 15:33:50.863 19954-19954/ir.malv.plusdependencytest W/HMSSDK_CountryCodeBean: countryCode from system language is not reliable.
2020-09-16 15:33:50.864 19954-19954/ir.malv.plusdependencytest E/HMSSDK_HMSBIInitializer: Failed to get device issue country
2020-09-16 15:33:50.909 19954-19954/ir.malv.plusdependencytest I/HMSSDK_HMSPackageManager: Succeed to find HMS apk: com.huawei.hwid version: 40100308
2020-09-16 15:33:50.934 19954-20000/ir.malv.plusdependencytest I/HMSSDK_HMSBIInitializer: Builder->biInitFlag :false
2020-09-16 15:33:50.936 19954-20000/ir.malv.plusdependencytest I/HMSSDK_HMSBIInitializer: Builder->biSetting :false
2020-09-16 15:33:50.936 19954-19954/ir.malv.plusdependencytest I/HMSSDK_HMSBIInitializer: Builder->biInitFlag :false
2020-09-16 15:33:50.937 19954-20000/ir.malv.plusdependencytest I/HMSSDK_CountryCodeBean: getCountryCode get country code from SIM_COUNTRY
2020-09-16 15:33:50.938 19954-19954/ir.malv.plusdependencytest I/HMSSDK_HMSBIInitializer: Builder->biSetting :false
2020-09-16 15:33:50.939 19954-20000/ir.malv.plusdependencytest W/HMSSDK_CountryCodeBean: countryCode from system language is not reliable.
2020-09-16 15:33:50.940 19954-20000/ir.malv.plusdependencytest E/HMSSDK_HMSBIInitializer: Failed to get device issue country
2020-09-16 15:33:50.953 19954-20000/ir.malv.plusdependencytest I/HMSSDK_HiAnalyticsUtils: issueCountry initial
2020-09-16 15:33:50.953 19954-19954/ir.malv.plusdependencytest I/HMSSDK_HiAnalyticsUtils: issueCountry initial
2020-09-16 15:33:50.954 19954-20000/ir.malv.plusdependencytest I/HMSSDK_CountryCodeBean: getCountryCode get country code from SIM_COUNTRY
2020-09-16 15:33:50.954 19954-19954/ir.malv.plusdependencytest I/HMSSDK_CountryCodeBean: getCountryCode get country code from SIM_COUNTRY
2020-09-16 15:33:50.956 19954-19954/ir.malv.plusdependencytest W/HMSSDK_CountryCodeBean: countryCode from system language is not reliable.
2020-09-16 15:33:50.956 19954-20000/ir.malv.plusdependencytest W/HMSSDK_CountryCodeBean: countryCode from system language is not reliable.
2020-09-16 15:33:50.956 19954-19954/ir.malv.plusdependencytest I/HMSSDK_HiAnalyticsUtils: not ChinaROM
2020-09-16 15:33:50.956 19954-20000/ir.malv.plusdependencytest I/HMSSDK_HiAnalyticsUtils: not ChinaROM
2020-09-16 15:33:50.959 19954-20000/ir.malv.plusdependencytest I/HMSSDK_HiAnalyticsUtils: hw_app_analytics_state value is 0
2020-09-16 15:33:50.959 19954-19954/ir.malv.plusdependencytest I/HMSSDK_HiAnalyticsUtils: hw_app_analytics_state value is 0
2020-09-16 15:33:50.960 19954-19954/ir.malv.plusdependencytest I/HMSSDK_HmsMessaging: invoke turnOnPush
2020-09-16 15:33:50.963 19954-19954/ir.malv.plusdependencytest I/HMSSDK_HmsMessaging: turn on/off with AIDL
2020-09-16 15:33:50.970 19954-20004/ir.malv.plusdependencytest I/HMSSDK_HuaweiApiManager: sendRequest
2020-09-16 15:33:50.971 19954-20004/ir.malv.plusdependencytest I/HMSSDK_BaseHmsClient: ====== HMSSDK version: 50000301 ======
2020-09-16 15:33:50.972 19954-20004/ir.malv.plusdependencytest I/HMSSDK_BaseHmsClient: Enter connect, Connection Status: 1
2020-09-16 15:33:50.973 19954-20004/ir.malv.plusdependencytest I/HMSSDK_BaseHmsClient: connect minVersion:30000000
2020-09-16 15:33:50.975 19954-20004/ir.malv.plusdependencytest I/HMSSDK_Util: available exist: true
2020-09-16 15:33:50.976 19954-20004/ir.malv.plusdependencytest E/HMSSDK_Util: In isAvailableLibExist, Failed to read meta data for the availableLoaded.
2020-09-16 15:33:50.977 19954-20004/ir.malv.plusdependencytest I/HMSSDK_Util: available exist: true
2020-09-16 15:33:50.981 19954-20004/ir.malv.plusdependencytest I/HMSSDK_HMSPackageManager: current versionCode:40100308, minimum version requirements: 30000000
2020-09-16 15:33:50.986 19954-20004/ir.malv.plusdependencytest I/HMSSDK_BaseHmsClient: check available result: 0
2020-09-16 15:33:50.987 19954-20004/ir.malv.plusdependencytest I/HMSSDK_BaseHmsClient: enter bindCoreService
2020-09-16 15:33:51.007 19954-20004/ir.malv.plusdependencytest I/HMSSDK_HuaweiApiManager: sendRequest
2020-09-16 15:33:51.008 19954-20004/ir.malv.plusdependencytest I/HMSSDK_BaseHmsClient: ====== HMSSDK version: 50000301 ======
2020-09-16 15:33:51.009 19954-20004/ir.malv.plusdependencytest I/HMSSDK_BaseHmsClient: Enter connect, Connection Status: 1
2020-09-16 15:33:51.010 19954-20004/ir.malv.plusdependencytest I/HMSSDK_BaseHmsClient: connect minVersion:30000000
2020-09-16 15:33:51.010 19954-20004/ir.malv.plusdependencytest I/HMSSDK_Util: available exist: true
2020-09-16 15:33:51.013 19954-20004/ir.malv.plusdependencytest I/HMSSDK_HMSPackageManager: current versionCode:40100308, minimum version requirements: 30000000
2020-09-16 15:33:51.016 19954-20004/ir.malv.plusdependencytest I/HMSSDK_BaseHmsClient: check available result: 0
2020-09-16 15:33:51.017 19954-20004/ir.malv.plusdependencytest I/HMSSDK_BaseHmsClient: enter bindCoreService
2020-09-16 15:33:51.681 19954-19954/ir.malv.plusdependencytest I/HMSSDK_BinderAdapter: Enter onServiceConnected.
2020-09-16 15:33:51.682 19954-19954/ir.malv.plusdependencytest I/HMSSDK_BaseHmsClient: Enter onServiceConnected.
2020-09-16 15:33:51.684 19954-19954/ir.malv.plusdependencytest I/HMSSDK_BinderAdapter: Enter onServiceConnected.
2020-09-16 15:33:51.684 19954-20004/ir.malv.plusdependencytest I/HMSSDK_HmsClient: post msg api_name:push.setNotifyFlag, app_id:102760085|, pkg_name:ir.malv.plusdependencytest, sdk_version:50000301, session_id:*, transaction_id:102760085fyFlag20200916153350948378003, kitSdkVersion:50002300, apiLevel:1
2020-09-16 15:33:51.685 19954-19954/ir.malv.plusdependencytest I/HMSSDK_BaseHmsClient: Enter onServiceConnected.
2020-09-16 15:33:51.689 19954-20004/ir.malv.plusdependencytest I/HMSSDK_BaseAdapter: in baseRequest + uri is :push.setNotifyFlag, transactionId is : 102760085fyFlag20200916153350948378003
2020-09-16 15:33:51.692 19954-20004/ir.malv.plusdependencytest I/HMSSDK_PendingResultImpl: init uri:push.setNotifyFlag
2020-09-16 15:33:51.694 19954-20004/ir.malv.plusdependencytest I/HMSSDK_PendingResultImpl: setResultCallback
2020-09-16 15:33:51.698 19954-20004/ir.malv.plusdependencytest I/HMSSDK_HmsClient: post msg api_name:push.gettoken, app_id:102760085|, pkg_name:ir.malv.plusdependencytest, sdk_version:50000301, session_id:*, transaction_id:102760085ttoken20200916153350948306787, kitSdkVersion:50002300, apiLevel:1
2020-09-16 15:33:51.706 19954-20004/ir.malv.plusdependencytest I/HMSSDK_BaseAdapter: in baseRequest + uri is :push.gettoken, transactionId is : 102760085ttoken20200916153350948306787
2020-09-16 15:33:51.708 19954-20004/ir.malv.plusdependencytest I/HMSSDK_PendingResultImpl: init uri:push.gettoken
2020-09-16 15:33:51.709 19954-20004/ir.malv.plusdependencytest I/HMSSDK_PendingResultImpl: setResultCallback
2020-09-16 15:33:51.720 19954-19972/ir.malv.plusdependencytest I/HMSSDK_PendingResultImpl: setResult:0
2020-09-16 15:33:51.745 19954-19954/ir.malv.plusdependencytest I/HMSSDK_BaseAdapter: baseCallBack.onComplete
2020-09-16 15:33:51.746 19954-19954/ir.malv.plusdependencytest I/HMSSDK_HmsClient: receive msg status_code:0, error_code0, api_name:push.setNotifyFlag, app_id:102760085|, pkg_name:ir.malv.plusdependencytest, session_id:*, transaction_id:102760085fyFlag20200916153350948378003, resolution:null
2020-09-16 15:33:51.748 19954-19954/ir.malv.plusdependencytest I/HMSSDK_BaseVoidTask: Operate succeed
2020-09-16 15:33:51.771 19954-19972/ir.malv.plusdependencytest I/HMSSDK_PendingResultImpl: setResult:0
2020-09-16 15:33:51.837 19954-19954/ir.malv.plusdependencytest I/HMSSDK_BaseAdapter: baseCallBack.onComplete
2020-09-16 15:33:51.839 19954-19954/ir.malv.plusdependencytest I/HMSSDK_HmsClient: receive msg status_code:0, error_code0, api_name:push.gettoken, app_id:102760085|, pkg_name:ir.malv.plusdependencytest, session_id:*, transaction_id:102760085ttoken20200916153350948306787, resolution:null
2020-09-16 15:33:51.842 19954-19954/ir.malv.plusdependencytest I/HMSSDK_HmsInstanceId: GetTokenTask receive a empty token, please check HmsMessageService.onNewToken receive result.

Logs with Tag=pushlog:

2020-09-16 20:15:10.585 7731-24998/? I/PushLog40100308_HMS: [Core-GWTask-84-859]enter set self show message control flag, req:{"enable":true,"packageName":"ir.malv.plusdependencytest"}(:289)
2020-09-16 20:15:10.586 7731-24998/? I/PushLog40100308_HMS: [Core-GWTask-84-859]init uri:pushcore.enableNotify(:289)
2020-09-16 20:15:10.586 7731-24998/? I/PushLog40100308_HMS: [Core-GWTask-84-859]await(:289)
2020-09-16 20:15:10.586 7731-24998/? I/PushLog40100308_HMS: [Core-GWTask-84-859]awaitOnAnyThread timeout:10 unit:SECONDS(:289)
2020-09-16 20:15:10.588 6359-25003/? I/PushLog100101302: [IO-pool-thread-36-1644]Request, URI: pushcore.enableNotify, clientId: {packageName: com.huawei.hwid, sdkVersion: 10000000, originPackageName: ir.malv.plusdependencytest, originAppId: 102760085, originHostAppId: 102760085, originSdkVersion: 50000301}
2020-09-16 20:15:10.588 6359-25003/? I/PushLog100101302: [IO-pool-thread-36-1644]enter enable notify request:EnableNotifyReq{packageName='ir.malv.plusdependencytest', enable=true}
2020-09-16 20:15:10.590 6359-25003/? I/PushLog100101302: [IO-pool-thread-36-1644]Response, uri: pushcore.enableNotify, statusCode: 0
2020-09-16 20:15:10.591 7731-24999/? I/PushLog40100308_HMS: [Core-GWTask-85-860]enter get token request:com.huawei.hms.support.api.entity.push.TokenReq{ pkgName: ir.malv.plusdependencytest isFirstTime: true scope: null appId: null} , transactionId:102760085ttoken20200916201509611018781(:289)
2020-09-16 20:15:10.592 7731-19020/? I/PushLog40100308_HMS: [Binder:7731_7-784]setResult:0(:289)
2020-09-16 20:15:10.592 7731-24999/? I/PushLog40100308_HMS: [Core-GWTask-85-860]init uri:pushcore.gettoken(:289)
2020-09-16 20:15:10.593 7731-24999/? I/PushLog40100308_HMS: [Core-GWTask-85-860]await(:289)
2020-09-16 20:15:10.593 7731-24999/? I/PushLog40100308_HMS: [Core-GWTask-85-860]awaitOnAnyThread timeout:10 unit:SECONDS(:289)
2020-09-16 20:15:10.595 6359-25001/? I/PushLog100101302: [IO-pool-thread-35-1642]Request, URI: pushcore.gettoken, clientId: {packageName: com.huawei.hwid, sdkVersion: 10000000, originPackageName: ir.malv.plusdependencytest, originAppId: 102760085, originHostAppId: 102760085, originSdkVersion: 50000301}
2020-09-16 20:15:10.595 6359-25001/? I/PushLog100101302: [IO-pool-thread-35-1642]GetTokenRequest: com.huawei.android.pushagent.core.support.entity.TokenReq{ pkgName: ir.malv.plusdependencytest},userId:0,transactionId:102760085ttoken20200916201509611018781
2020-09-16 20:15:10.596 6359-25001/? I/PushLog100101302: [IO-pool-thread-35-1642]check push connection is not exist, reconnect it.
2020-09-16 20:15:10.599 6359-25001/? I/PushLog100101302: [IO-pool-thread-35-1642]dispatchIntent over
2020-09-16 20:15:10.599 6359-25001/? I/PushLog100101302: [IO-pool-thread-35-1642]TRS exceed valid time, so need to query TRS again
2020-09-16 20:15:10.600 6359-6417/? I/PushLog100101302: [ReceiverDispatcher-383]com.huawei.action.CONNECT_PUSHSRV alarm trigger, expectTriggerTime:0, current trigger time:1600271110600
2020-09-16 20:15:10.602 6359-6417/? I/PushLog100101302: [ReceiverDispatcher-383]connect srv: TRS is invalid, so need to query TRS
2020-09-16 20:15:10.604 6359-25001/? I/PushLog100101302: [IO-pool-thread-35-1642]Not allow to use push in this area, and not pass interval,result code: 26, belong id is -1, server ip is , region of TRS server is -1
2020-09-16 20:15:10.613 6359-6417/? I/PushLog100101302: [ReceiverDispatcher-383]Not allow to use push in this area, and not pass interval,result code: 26, belong id is -1, server ip is , region of TRS server is -1
2020-09-16 20:15:10.613 6359-25001/? I/PushLog100101302: [IO-pool-thread-35-1642]begin to get token from pushSrv, pkgName : ir.malv.plusdependencytest, userId :00
2020-09-16 20:15:10.617 6359-25001/? I/PushLog100101302: [IO-pool-thread-35-1642]apply token: TRS is invalid, so need to query TRS
2020-09-16 20:15:10.624 6359-25001/? I/PushLog100101302: [IO-pool-thread-35-1642]Not allow to use push in this area, and not pass interval,result code: 26, belong id is -1, server ip is , region of TRS server is -1
2020-09-16 20:15:10.630 6359-25001/? I/PushLog100101302: [IO-pool-thread-35-1642]Response, uri: pushcore.gettoken, statusCode: 0
2020-09-16 20:15:10.632 7731-19020/? I/PushLog40100308_HMS: [Binder:7731_7-784]setResult:0(:289)
2020-09-16 20:15:10.636 7731-24999/? I/PushLog40100308_HMS: [Core-GWTask-85-860]request token for HMS from system push.(:289)
2020-09-16 20:15:10.640 7731-14337/? I/PushLog40100308_HMS: [Push-Task-1-717]request token for HMS by AIDL.(:289)
2020-09-16 20:15:10.641 7731-14337/? I/PushLog40100308_HMS: [Push-Task-1-717]init uri:pushcore.gettoken(:289)
2020-09-16 20:15:10.642 7731-14337/? I/PushLog40100308_HMS: [Push-Task-1-717]await(:289)
2020-09-16 20:15:10.642 7731-14337/? I/PushLog40100308_HMS: [Push-Task-1-717]awaitOnAnyThread timeout:10 unit:SECONDS(:289)
2020-09-16 20:15:10.644 6359-25003/? I/PushLog100101302: [IO-pool-thread-36-1644]Request, URI: pushcore.gettoken, clientId: {packageName: com.huawei.hwid, sdkVersion: 10000000, originPackageName: ir.malv.plusdependencytest, originAppId: 102760085, originHostAppId: 102760085, originSdkVersion: 50000301}
2020-09-16 20:15:10.644 6359-25003/? I/PushLog100101302: [IO-pool-thread-36-1644]GetTokenRequest: com.huawei.android.pushagent.core.support.entity.TokenReq{ pkgName: com.huawei.hwid},userId:0,transactionId:102760085ttoken20200916201509611018781
2020-09-16 20:15:10.645 6359-25003/? I/PushLog100101302: [IO-pool-thread-36-1644]check push connection is not exist, reconnect it.
2020-09-16 20:15:10.647 6359-25003/? I/PushLog100101302: [IO-pool-thread-36-1644]dispatchIntent over
2020-09-16 20:15:10.647 6359-25003/? I/PushLog100101302: [IO-pool-thread-36-1644]TRS exceed valid time, so need to query TRS again
2020-09-16 20:15:10.648 6359-6417/? I/PushLog100101302: [ReceiverDispatcher-383]com.huawei.action.CONNECT_PUSHSRV alarm trigger, expectTriggerTime:0, current trigger time:1600271110648
2020-09-16 20:15:10.653 6359-6417/? I/PushLog100101302: [ReceiverDispatcher-383]connect srv: TRS is invalid, so need to query TRS
2020-09-16 20:15:10.657 6359-6417/? I/PushLog100101302: [ReceiverDispatcher-383]Not allow to use push in this area, and not pass interval,result code: 26, belong id is -1, server ip is , region of TRS server is -1
2020-09-16 20:15:10.657 6359-25003/? I/PushLog100101302: [IO-pool-thread-36-1644]Not allow to use push in this area, and not pass interval,result code: 26, belong id is -1, server ip is , region of TRS server is -1
2020-09-16 20:15:10.664 6359-25003/? I/PushLog100101302: [IO-pool-thread-36-1644]begin to get token from pushSrv, pkgName : com.huawei.hwid, userId :00
2020-09-16 20:15:10.667 6359-25003/? I/PushLog100101302: [IO-pool-thread-36-1644]apply token: TRS is invalid, so need to query TRS
    Tags: [Huawei]
    Message: Succefully turned on Push
2020-09-16 20:15:10.675 6359-25003/? I/PushLog100101302: [IO-pool-thread-36-1644]Not allow to use push in this area, and not pass interval,result code: 26, belong id is -1, server ip is , region of TRS server is -1
2020-09-16 20:15:10.678 6359-25003/? I/PushLog100101302: [IO-pool-thread-36-1644]Response, uri: pushcore.gettoken, statusCode: 0
2020-09-16 20:15:10.679 7731-8371/? I/PushLog40100308_HMS: [Binder:7731_6-640]setResult:0(:289)
2020-09-16 20:15:23.427 7731-25033/? I/PushLog40100308_HMS: [Core-GWTask-86-862]enter get token request:com.huawei.hms.support.api.entity.push.TokenReq{ pkgName: ir.malv.plusdependencytest isFirstTime: false scope: null appId: null} , transactionId:102760085ttoken20200916201523364702182(:289)
2020-09-16 20:15:23.428 7731-25033/? I/PushLog40100308_HMS: [Core-GWTask-86-862]init uri:pushcore.gettoken(:289)
2020-09-16 20:15:23.429 7731-25033/? I/PushLog40100308_HMS: [Core-GWTask-86-862]await(:289)
2020-09-16 20:15:23.429 7731-25033/? I/PushLog40100308_HMS: [Core-GWTask-86-862]awaitOnAnyThread timeout:10 unit:SECONDS(:289)
2020-09-16 20:15:23.432 6359-25001/? I/PushLog100101302: [IO-pool-thread-35-1642]Request, URI: pushcore.gettoken, clientId: {packageName: com.huawei.hwid, sdkVersion: 10000000, originPackageName: ir.malv.plusdependencytest, originAppId: 102760085, originHostAppId: 102760085, originSdkVersion: 50000301}
2020-09-16 20:15:23.433 6359-25001/? I/PushLog100101302: [IO-pool-thread-35-1642]GetTokenRequest: com.huawei.android.pushagent.core.support.entity.TokenReq{ pkgName: ir.malv.plusdependencytest},userId:0,transactionId:102760085ttoken20200916201523364702182
2020-09-16 20:15:23.433 6359-25001/? I/PushLog100101302: [IO-pool-thread-35-1642]check push connection is not exist, reconnect it.
2020-09-16 20:15:23.436 6359-25001/? I/PushLog100101302: [IO-pool-thread-35-1642]dispatchIntent over
2020-09-16 20:15:23.436 6359-25001/? I/PushLog100101302: [IO-pool-thread-35-1642]TRS exceed valid time, so need to query TRS again
2020-09-16 20:15:23.437 6359-6417/? I/PushLog100101302: [ReceiverDispatcher-383]com.huawei.action.CONNECT_PUSHSRV alarm trigger, expectTriggerTime:0, current trigger time:1600271123437
2020-09-16 20:15:23.439 6359-6417/? I/PushLog100101302: [ReceiverDispatcher-383]connect srv: TRS is invalid, so need to query TRS
2020-09-16 20:15:23.443 6359-25001/? I/PushLog100101302: [IO-pool-thread-35-1642]Not allow to use push in this area, and not pass interval,result code: 26, belong id is -1, server ip is , region of TRS server is -1
2020-09-16 20:15:23.444 6359-6417/? I/PushLog100101302: [ReceiverDispatcher-383]Not allow to use push in this area, and not pass interval,result code: 26, belong id is -1, server ip is , region of TRS server is -1
2020-09-16 20:15:23.449 6359-25001/? I/PushLog100101302: [IO-pool-thread-35-1642]begin to get token from pushSrv, pkgName : ir.malv.plusdependencytest, userId :00
2020-09-16 20:15:23.453 6359-25001/? I/PushLog100101302: [IO-pool-thread-35-1642]apply token: TRS is invalid, so need to query TRS
2020-09-16 20:15:23.458 6359-25001/? I/PushLog100101302: [IO-pool-thread-35-1642]Not allow to use push in this area, and not pass interval,result code: 26, belong id is -1, server ip is , region of TRS server is -1
2020-09-16 20:15:23.462 6359-25001/? I/PushLog100101302: [IO-pool-thread-35-1642]Response, uri: pushcore.gettoken, statusCode: 0
2020-09-16 20:15:23.462 7731-8371/? I/PushLog40100308_HMS: [Binder:7731_6-640]setResult:0(:289)
2020-09-16 20:15:23.465 7731-25033/? I/PushLog40100308_HMS: [Core-GWTask-86-862]request token for HMS from system push.(:289)
2020-09-16 20:15:23.465 7731-14337/? I/PushLog40100308_HMS: [Push-Task-1-717]request token for HMS by AIDL.(:289)
2020-09-16 20:15:23.466 7731-14337/? I/PushLog40100308_HMS: [Push-Task-1-717]init uri:pushcore.gettoken(:289)
2020-09-16 20:15:23.466 7731-14337/? I/PushLog40100308_HMS: [Push-Task-1-717]await(:289)
2020-09-16 20:15:23.466 7731-14337/? I/PushLog40100308_HMS: [Push-Task-1-717]awaitOnAnyThread timeout:10 unit:SECONDS(:289)
2020-09-16 20:15:23.469 6359-25003/? I/PushLog100101302: [IO-pool-thread-36-1644]Request, URI: pushcore.gettoken, clientId: {packageName: com.huawei.hwid, sdkVersion: 10000000, originPackageName: ir.malv.plusdependencytest, originAppId: 102760085, originHostAppId: 102760085, originSdkVersion: 50000301}
2020-09-16 20:15:23.470 6359-25003/? I/PushLog100101302: [IO-pool-thread-36-1644]GetTokenRequest: com.huawei.android.pushagent.core.support.entity.TokenReq{ pkgName: com.huawei.hwid},userId:0,transactionId:102760085ttoken20200916201523364702182
2020-09-16 20:15:23.471 6359-25003/? I/PushLog100101302: [IO-pool-thread-36-1644]check push connection is not exist, reconnect it.
2020-09-16 20:15:23.474 6359-25003/? I/PushLog100101302: [IO-pool-thread-36-1644]dispatchIntent over
2020-09-16 20:15:23.474 6359-25003/? I/PushLog100101302: [IO-pool-thread-36-1644]TRS exceed valid time, so need to query TRS again
2020-09-16 20:15:23.476 6359-6417/? I/PushLog100101302: [ReceiverDispatcher-383]com.huawei.action.CONNECT_PUSHSRV alarm trigger, expectTriggerTime:0, current trigger time:1600271123476
2020-09-16 20:15:23.480 6359-25003/? I/PushLog100101302: [IO-pool-thread-36-1644]Not allow to use push in this area, and not pass interval,result code: 26, belong id is -1, server ip is , region of TRS server is -1
2020-09-16 20:15:23.481 6359-6417/? I/PushLog100101302: [ReceiverDispatcher-383]connect srv: TRS is invalid, so need to query TRS
2020-09-16 20:15:23.487 6359-25003/? I/PushLog100101302: [IO-pool-thread-36-1644]begin to get token from pushSrv, pkgName : com.huawei.hwid, userId :00
2020-09-16 20:15:23.491 6359-25003/? I/PushLog100101302: [IO-pool-thread-36-1644]apply token: TRS is invalid, so need to query TRS
2020-09-16 20:15:23.492 6359-6417/? I/PushLog100101302: [ReceiverDispatcher-383]Not allow to use push in this area, and not pass interval,result code: 26, belong id is -1, server ip is , region of TRS server is -1
2020-09-16 20:15:23.500 6359-25003/? I/PushLog100101302: [IO-pool-thread-36-1644]Not allow to use push in this area, and not pass interval,result code: 26, belong id is -1, server ip is , region of TRS server is -1
2020-09-16 20:15:23.503 6359-25003/? I/PushLog100101302: [IO-pool-thread-36-1644]Response, uri: pushcore.gettoken, statusCode: 0
2020-09-16 20:15:23.504 7731-8371/? I/PushLog40100308_HMS: [Binder:7731_6-640]setResult:0(:289)


Information about phone and app:

  • Phone: Huawei Y7p
  • Android: 10
  • EMUI: 10.1.0
  • AGConnect: 'com.huawei.agconnect:agcp:1.4.1.300'
  • PushKit: "com.huawei.hms:push:5.0.2.300"
  • AGConnect-Core: "com.huawei.agconnect:agconnect-core:1.4.1.300"
  • Auto init:
<meta-data
     android:name="push_kit_auto_init_enabled"
     android:value="true" />
  • HMS service:
<service
    android:name=".services.HmsService"
    android:exported="false">
     <intent-filter>
         <action android:name="com.huawei.push.action.MESSAGING_EVENT" />
     </intent-filter>
</service>

Some misc informations:

  • Same app CAN obtain HMS token on a Samsung G-A40 with HMS Core v5.0.0.304
  • No account synced with App Gallery and device is brand new
  • Region (Country and IP): Iran

Extra informations requested:

  • Galaxy A40 logs from 0 to sending uplink [Link]
  • Galaxy A40 logs with Phone permission allowed for HMS core Link
like image 469
Mahdi-Malv Avatar asked Sep 16 '20 11:09

Mahdi-Malv


People also ask

What is Huawei push?

Huawei Push Kit is a messaging service provided by Huawei for developers. It establishes a communication channel between the cloud and devices. By using Huawei Push Kit, developers can send the latest messages to users. This helps developers maintain closer ties with users and increases user awareness and activity.

What is push token in android?

Push tokens are a unique anonymous identifier generated by a user's device and sent to Braze to identify where to send each recipient's notification. If a device doesn't have a push token, there is no way to send push to it. Push tokens are generated by push service providers.

Does HMS push kit provides the capability of automatically applying for tokens?

Automatic InitializationThe HMS Core Push SDK provides the capability of automatically generating AAIDs and automatically applying for tokens. You can enable or disable automatic initialization by calling Push.


Video Answer


1 Answers

Mixing the automatic push_kit_auto_init_enabled and manual retrieval methods getToken() together will result into problems.

We had a similar issue where tokens sometimes are received and other times they weren't. It seemed very random but as a basic rule you should either use one of the automatic methods described here or you stick to this section which describes how to apply for a token as soon as you finished all the configurations (part 1, part 2, part 3 and part 4).

That should solve the issue for anyone else having this issue in a country where push messages are allowed.

like image 172
devEnju Avatar answered Nov 05 '22 21:11

devEnju