本演示项目在Unity for Android Build中启用部分华为HMS和AGC服务,对应的类和函数的名称和用法相同。
您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

85 行
3.0 KiB

using HuaweiAuthDemo;
using HuaweiService;
using HuaweiService.Auth;
using UnityEngine;
namespace HuaweiAuthDemo
{
public class EmailSignUpPanel : AbstractPasswordConfirmationPanel
{
public void OnSignUpClicked()
{
EmailUser emailUser = new EmailUser.Builder()
.setEmail(emailorPhone.text)
.setVerifyCode(verifyCode.text)
.setPassword(password.text)
.build();
AGConnectAuth.getInstance().createUser(emailUser)
.addOnSuccessListener(new HuaweiOnsuccessListener<SignInResult>((signresult) =>
{
UnityMainThread.instance.AddJob(() =>
{
PanelController.popupinstance.ShowInfo("sign up successfully!");
PanelController.userInfo.ParentPanel = this;
PanelController.getInstance().OpenPanel(PanelController.userInfo);
});
})).addOnFailureListener(new HuaweiOnFailureListener((e
) =>
{
UnityMainThread.instance.AddJob(() =>
{
Error error = new Error();
error.message = "Login failed" + e.ToString();
PanelController.popupinstance.ShowError(error);
});
}));
}
public void verify()
{
bool result = false;
VerifyCodeSettings settings = new VerifyCodeSettings.Builder()
.action(VerifyCodeSettings.ACTION_REGISTER_LOGIN)
.sendInterval(30)
.locale(Locale.CHINA)
.build();
HuaweiService.Task task = EmailAuthProvider.requestVerifyCode(emailorPhone.text, settings);
task.addOnSuccessListener(TaskExecutors.uiThread(),
new HuaweiOnsuccessListener<VerifyCodeResult>(
(codeResult) =>
{
result = true;
UnityMainThread.instance.AddJob(() =>
{
PanelController.popupinstance.ShowInfo("sms code send successfully!");
});
}))
.addOnFailureListener(TaskExecutors.uiThread(), new HuaweiOnFailureListener((e) =>
{
UnityMainThread.instance.AddJob(() =>
{
Error error = new Error();
error.message = e.toString();
PanelController.popupinstance.ShowError(error);
});
}));
}
public void onVerifyButtonClick()
{
verify();
}
public override void OpenPanel()
{
base.OpenPanel();
}
}
}