跳到主要内容

User Profile

Read and update profile fields such as display name and phone number.

备注

userInstanceESPRMUser from User sign in.

What This Module Does ?

Loads user profile data and updates name or phone number (phone uses OTP confirmation).

Use Custom Data for app-specific JSON, geo coordinates, or timezone—not built-in profile fields.

Expected outcome: Updated profile visible on the next getUserInfo() call.

Common Workflows

Get user info

const userInfo = await userInstance.getUserInfo();
const userInfoWithCustom = await userInstance.getUserInfo(true);

Pass true to include custom data in the same response.

Update display name

await userInstance.updateName("John Doe");

Set phone number (two steps)

await userInstance.setPhoneNumber("+1234567890");
await userInstance.confirmPhoneNumber(verificationCode);

Error Handling

try {
await userInstance.confirmPhoneNumber(verificationCode);
} catch (error) {
console.error("Phone confirmation failed:", error);
}

Complete setPhoneNumber before confirming with the OTP from that step.

Best Practices

  1. Refresh UI after updateName or phone confirmation
  2. Use getUserInfo(true) sparingly if custom data is large
  3. Validate phone format in your app before setPhoneNumber

On this page