Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

华为获取pushtoken报错 #63

Open
cxygpt opened this issue Jul 14, 2022 · 7 comments
Open

华为获取pushtoken报错 #63

cxygpt opened this issue Jul 14, 2022 · 7 comments

Comments

@cxygpt
Copy link

cxygpt commented Jul 14, 2022

hms get token failed com.huawei.hms.common.ApiException: 907122050: operation in MAIN thread prohibited https://developer.huawei.com/consumer/cn/doc/development/HMSCore-References-V5/error-code-0000001050255690-V5

@taoweiji
Copy link
Owner

提供一下,错误堆栈

@cxygpt
Copy link
Author

cxygpt commented Jul 14, 2022

getRegisterId这个方法

提供一下,错误堆栈

getRegisterId这个方法放在子线程中就OK了

@git4wht
Copy link

git4wht commented Jul 14, 2022

getRegisterId 是Override 方法,现在是看到华为和荣耀的文档中明确提出需要在一个新线程中调用getToken

@cxygpt
Copy link
Author

cxygpt commented Jul 14, 2022

这样实现就没问题了
new Thread(() -> {
// read from agconnect-services.json
String appId = new AGConnectOptionsBuilder().build(context).getString("client/app_id");
try {
regId = HmsInstanceId.getInstance(context).getToken(appId, "HCM");
} catch (ApiException e) {
handler.getLogger().log(UnifiedHmsMessageService.TAG, "hms get token failed " + e.toString() + " https://developer.huawei.com/consumer/cn/doc/development/HMSCore-References-V5/error-code-0000001050255690-V5", e);
e.printStackTrace();
}
Log.e(UnifiedHmsMessageService.TAG, "get token:" + regId);
}).start();

@git4wht
Copy link

git4wht commented Jul 14, 2022

我也是这个样改了,荣耀只提供了 aar,Permission name PROCESS_PUSH_MSG is not unique

@cxygpt
Copy link
Author

cxygpt commented Jul 14, 2022

我也是这个样改了,荣耀只提供了 aar,Permission name PROCESS_PUSH_MSG is not unique

荣耀只能单独集成

@git4wht
Copy link

git4wht commented Jul 22, 2022

奇怪,2.3.9 好用了,不用单独放在独立线程里了。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants