华为Push Kit getToken抛出ApiException 6005: permission not authorized

Huawei Push Kit getToken throws ApiException 6005: permission not authorized

我正在开发一个使用华为推送服务的应用程序,直到最近几天它都运行良好

String appId = AGConnectServicesConfig.fromContext(this).getString("client/app_id");
String hmsToken = HmsInstanceId.getInstance(this).getToken(appId, DEFAULT_TOKEN_SCOPE);

开始抛出未经授权的异常我三次检查了我在应用程序库连接中的设置,一切看起来都很好

有人在华为开发者论坛上给了我这个答案并且有效。只需将 HMS 工具包插件添加到 Android 工作室和 运行 配置向导。它会检查您添加的所有华为服务以及 agcconnect.json 文件,并重建您的项目。