Unity 接入华为登录 HarmonyOS 鸿蒙Next

Unity 接入华为登录 HarmonyOS 鸿蒙Next 现在已经能点击登录了,

但是用这个方法

AccountAuthParamsHelper authParamsHelper = new AccountAuthParamsHelper();
authParamsHelper.SetAuthorizationCode().SetAccessToken().SetIdToken().SetUid().SetId().SetEmail().CreateParams();
HuaweiGameService.Login(_loginListener);

去调登录会导致游戏卡住不动

而且

这个监听好像没啥用,根本没走里面的流程

大家有遇到过么


更多关于Unity 接入华为登录 HarmonyOS 鸿蒙Next的实战教程也可以访问 https://www.itying.com/category-93-b0.html

3 回复

您好,您的问题比较复杂,请提供您的appid和集成sdk版本至工单咨询:https://developer.huawei.com/consumer/cn/support/feedback/#/

更多关于Unity 接入华为登录 HarmonyOS 鸿蒙Next的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html


在Unity中接入华为登录功能,针对HarmonyOS鸿蒙Next系统,主要步骤如下:

环境准备:

  • 确保Unity版本支持HarmonyOS开发。
  • 安装华为HMS Core插件,该插件提供了华为登录的API接口。

配置项目:

  • 在Unity项目中导入HMS Core插件。
  • 在华为开发者联盟注册应用,获取App ID和App Secret。

代码实现:

  • 在Unity脚本中初始化HMS Core SDK,使用App ID进行配置。
  • 调用华为登录API,实现用户登录功能。示例代码如下:
    using HuaweiMobileServices.Id;
    using HuaweiMobileServices.Utils;
    
    public class HuaweiLogin : MonoBehaviour
    {
        void Start()
        {
            HMSAccountManager.Instance.Init();
            HMSAccountManager.Instance.SignIn((authHuaweiId) =>
            {
                Debug.Log("Login Success: " + authHuaweiId.DisplayName);
            }, (error) =>
            {
                Debug.Log("Login Failed: " + error.Message);
            });
        }
    }
    

测试与发布:

  • 在Unity编辑器中运行项目,测试华为登录功能。
  • 打包项目为HarmonyOS应用,发布到华为应用市场。

通过以上步骤,可以在Unity项目中成功接入华为登录功能,适用于HarmonyOS鸿蒙Next系统。

在Unity中接入华为登录功能,需使用华为提供的HMS Core SDK。首先,在华为开发者联盟注册应用并获取App ID。然后,在Unity项目中导入HMS Unity Plugin,配置相关参数。接着,调用HMS提供的API实现登录功能,如HuaweiIdAuthService。最后,处理登录回调,获取用户信息。确保项目适配HarmonyOS鸿蒙Next系统,遵循华为的开发和发布规范。

回到顶部