鸿蒙HarmonyOS SDK
用户账号
手机和邮箱账号

手机和邮箱账号

手机验证码登录

await userManager.sendMobileLoginVerifyCode('+86', phone, 'zh-CN');
await userManager.loginWithMobile('+86', phone, verificationCode);

邮箱验证码登录

await userManager.sendEmailLoginVerifyCode(email, 'zh-CN');
await userManager.loginWithEmail(email, verificationCode);

手机号注册

await userManager.sendMobileRegisterVerifyCode('+86', phone, 'zh-CN');
const mobileToken = await userManager.registerWithMobile(
  '+86',
  phone,
  verificationCode,
  password
);
userManager.updateAuthorizeData(mobileToken);

registerWithPhone(phoneCode, phone, password, verificationCode) 是参数顺序不同的兼容接口。

邮箱注册

await userManager.sendEmailRegisterVerifyCode(email, 'zh-CN');
const emailToken = await userManager.registerWithEmail(email, verificationCode, password);
userManager.updateAuthorizeData(emailToken);

验证码发送和校验可能受频率限制。请捕获 Promise 异常并转换为适合的 ArkUI 提示。