HarmonyOS鸿蒙Next中应用内评论弹窗登录了华为ID日志报The user has not signed in to their HUAWEI ID.

HarmonyOS鸿蒙Next中应用内评论弹窗登录了华为ID日志报The user has not signed in to their HUAWEI ID.

try {
  const uiContext = this.getUIContext().getHostContext() as common.UIAbilityContext;
  commentManager.showCommentDialog(uiContext).then(()=>{
    LogUtil.logI(this.TAG, "succeeded in showing commentDialog.");
  }).catch((error: BusinessError<Object>) => {
    LogUtil.logE(this.TAG, `showCommentDialog failed, Code: ${error.code}, message: ${error.message}`);
  });
} catch (error) {
  LogUtil.logE(this.TAG, `showCommentDialog failed, Code: ${error.code}, message: ${error.message}`);
}

更多关于HarmonyOS鸿蒙Next中应用内评论弹窗登录了华为ID日志报The user has not signed in to their HUAWEI ID.的实战教程也可以访问 https://www.itying.com/category-93-b0.html

4 回复

开发者您好,The user has not signed in to their HUAWEI ID.这个错误请参考文档:1021500006 未登录华为账号。文档上描述这个错误是由于未登录华为账号引起的,请确认下是否登录了华为账号,我本地测试使用您的代码是可以拉起评论弹窗并进行评论,您可以参考下:

import { commentManager } from '@kit.AppGalleryKit';
import { hilog } from '@kit.PerformanceAnalysisKit';
import type { common } from '@kit.AbilityKit';
import { BusinessError } from '@kit.BasicServicesKit';

@Entry
@Component
struct showCommentDialogDemo {
  @State message: string = 'showCommentDialog'

  build() {
    Row() {
      Column() {
        Text(this.message)
          .fontSize(50)
          .fontWeight(FontWeight.Bold)
          .onClick(() => {
            try {
              const uiContext = this.getUIContext().getHostContext() as common.UIAbilityContext;
              commentManager.showCommentDialog(uiContext).then(()=>{
                hilog.info(0, 'TAG', "succeeded in showing commentDialog.");
              }).catch((error: BusinessError<Object>) => {
                hilog.error(0, 'TAG', `showCommentDialog failed, Code: ${error.code}, message: ${error.message}`);
              });
            } catch (error) {
              hilog.error(0, 'TAG', `showCommentDialog failed, Code: ${error.code}, message: ${error.message}`);
            }
          })
      }
      .width('100%')
    }
    .height('100%')
  }
}

如果仍未解决您的问题,请提供下详细的错误日志,以及您的版本信息(DevEco Studio版本信息和测试手机的版本信息)。

更多关于HarmonyOS鸿蒙Next中应用内评论弹窗登录了华为ID日志报The user has not signed in to their HUAWEI ID.的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html


你是不是没有上架 获取不到 appid

鸿蒙Next中应用内评论弹窗登录华为ID后日志仍报“The user has not signed in to their HUAWEI ID”,此问题通常由以下原因导致:

  1. 华为帐号服务(Account Kit)未正确集成或配置,需检查agconnect-services.json文件及依赖。
  2. 应用签名证书指纹与AGC平台配置不一致。
  3. 用户授权登录后,获取帐号信息的时机或方式有误,未成功获取到有效的AccountInfo对象。
  4. 设备系统时间或网络状态异常,影响帐号服务鉴权。

这个错误日志 The user has not signed in to their HUAWEI ID 表明,在调用 commentManager.showCommentDialog() 方法时,系统检测到当前设备上没有用户登录华为帐号。

原因分析:

应用内评论弹窗 (commentManager.showCommentDialog) 功能需要用户登录华为帐号才能使用。该弹窗会引导用户对应用进行评分和评论,这些操作需要关联到用户的真实身份(华为帐号)。如果设备当前未登录任何华为帐号,系统就会抛出此错误。

解决方案:

在调用评论弹窗之前,必须确保用户已登录华为帐号。你需要先集成并调用华为帐号服务(Account Kit)进行登录。

核心步骤:

  1. 集成Account Kit:在你的HarmonyOS Next应用中引入 @ohos.account.osAccount@ohos.account.appAccount 相关能力,以使用华为帐号服务。
  2. 检查登录状态:在触发评论弹窗前,先检查当前设备上的默认帐号是否已登录。可以使用 appAccount 模块的相关接口来查询帐号状态。
  3. 引导登录:如果检测到用户未登录,你应该先引导用户完成华为帐号登录流程。这通常通过拉起系统的帐号授权页面来实现。
  4. 登录后调用:在确认用户成功登录后,再执行 commentManager.showCommentDialog(uiContext) 来弹出评论窗口。

代码逻辑调整建议:

你的调用代码应嵌入在一个更完整的帐号状态检查逻辑之后。伪代码逻辑如下:

// 1. 检查帐号登录状态
import account_appAccount from '@ohos.account.appAccount';

// ... 获取帐号列表并检查是否有已登录的华为帐号 ...

// 2. 如果未登录,则先调用帐号服务接口引导登录
// 例如,使用 createAppAccountManager 和 authenticate 方法拉起登录界面
if (/* 未登录 */) {
    // 引导用户登录华为帐号
    // await account_appAccount.authenticate(...);
}

// 3. 确认登录成功后,再调用评论弹窗
try {
  const uiContext = this.getUIContext().getHostContext() as common.UIAbilityContext;
  commentManager.showCommentDialog(uiContext).then(()=>{
    LogUtil.logI(this.TAG, "succeeded in showing commentDialog.");
  }).catch((error: BusinessError<Object>) => {
    LogUtil.logE(this.TAG, `showCommentDialog failed, Code: ${error.code}, message: ${error.message}`);
  });
} catch (error) {
  LogUtil.logE(this.TAG, `showCommentDialog failed, Code: ${error.code}, message: ${error.message}`);
}

总结:

问题根源在于调用时序。showCommentDialog 不是一个独立的接口,它依赖于前置的帐号登录状态。请务必按照“检查登录 → 如需则引导登录 → 登录成功后调用评论”的流程来组织你的代码。请参考HarmonyOS官方文档中关于 Account Kit应用内评论(Comment Manager) 的详细API说明和开发指南,以获取准确的接口使用方法和参数。

回到顶部