User Profile
Read and update profile fields such as display name and phone number.
备注
userInstance — ESPRMUser 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
- Refresh UI after
updateNameor phone confirmation - Use
getUserInfo(true)sparingly if custom data is large - Validate phone format in your app before
setPhoneNumber
Related Resource
- API Reference: