sud.getUserInfo
Retrieves basic user information (nickname and avatar). This is non-sensitive data with no encryption flow, so it can be used directly on the client.
Parameters
Object object
| Property | Type | Default | Required | Description |
|---|---|---|---|---|
| success | function | No | Callback for a successful retrieval | |
| fail | function | No | Callback for a failed retrieval | |
| complete | function | No | Callback invoked when the call ends, after either success or failure |
Callback Parameters
success
| Property | Type | Description |
|---|---|---|
| nickname | string | User nickname |
| avatar | string | User avatar |
fail
| Property | Type | Description |
|---|---|---|
| errCode | number | Error code |
| errMsg | string | Error message |
complete carries no arguments. It is invoked after success or fail, and runs only once per request.
Notes
- This API returns only public basic information and contains no sensitive fields such as phone number or real name. Use sud.getUserProfile when sensitive information is required.
- The result does not include an
avatarUrlfield.avatarUrl(the remote avatar URL) is returned only in theuserInfoofsud.getUserProfile(). - Users may change their nickname and avatar. If you need to display them over time, persist them on Game SVR and retrieve them again before use instead of caching them once.
- If the user has not authorized yet, complete authorization through a user-initiated action first. See Getting User Info.
Example Code
javascript
sud.getUserInfo({
success: (res) => {
console.log('User nickname', res.nickname);
console.log('User avatar', res.avatar);
},
fail: (err) => {
console.error('Failed to get user info', err.errCode, err.errMsg);
},
complete: () => {
console.log('Get user info call finished');
},
});