【发布时间】:2020-08-06 16:08:26
【问题描述】:
我正在使用以下代码 sn-p,但是我仍然无法获取 pushToken。
private void obtainToken() {
// get token
new Thread() {
@Override
public void run() {
try {
String appId = AGConnectServicesConfig.fromContext(MainActivity.this).getString("client/app_id");
pushtoken = HmsInstanceId.getInstance(MainActivity.this).getToken(appId, "HCM");
if(!TextUtils.isEmpty(pushtoken)) {
Log.i(TAG, "get token:" + pushtoken);
}
} catch (Exception e) {
Log.i(TAG,"getToken failed, " + e);
}
}
}.start();
}
【问题讨论】:
-
请查看logcat。
-
我也面临这个问题,并收到以下错误:
I/HMSSDK_HmsClient: receive msg status_code:1, error_code907135000, api_name:push.gettoken, app_id:|, pkg_name:com.xxxx.android, session_id:*, transaction_id:000000000ttoken20200521161603156246407, resolution:null I/MainActivity: gettoken failed, com.huawei.hms.common.ApiException: 907135000: arguments invalid -
@CacheMeOutside 您可以从日志消息中非常清楚地看到您的 app_id 在清单中未正确设置。
标签: android push-notification push huawei-mobile-services huawei-push-notification