HarmonyOS Native SDK
User Account
Mobile and Email Account

Mobile and Email Account

Mobile verification-code login

await userManager.sendMobileLoginVerifyCode('+1', phone, 'en-US');
await userManager.loginWithMobile('+1', phone, verificationCode);

Email verification-code login

await userManager.sendEmailLoginVerifyCode(email, 'en-US');
await userManager.loginWithEmail(email, verificationCode);

Mobile registration

await userManager.sendMobileRegisterVerifyCode('+1', phone, 'en-US');
const mobileToken = await userManager.registerWithMobile(
  '+1',
  phone,
  verificationCode,
  password
);
userManager.updateAuthorizeData(mobileToken);

registerWithPhone(phoneCode, phone, password, verificationCode) is a compatibility API with a different parameter order.

Email registration

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

Verification-code delivery and validation can be rate limited. Catch rejected Promises and map them to suitable ArkUI feedback.