用户资料
获取与更新用户资料;资料由应用自有用户体系维护,IM 服务不强制托管。
平台调用风格
回调式(callback-last):有返回数据用 ResultCallback<T>,无返回数据用 OperationCallback;所有回调在主线程投递。
接口一览
| 操作 | 语义 | 传输 | 返回 |
|---|---|---|---|
getUserProfile | 查询用户资料。 | REST(客户端) | UserProfile |
updateMyUserProfile | 修改本人资料(name/avatarUrl)。 | REST(客户端) | UserProfile |
本页 2 个操作,其中 2 个在本平台绑定中声明了方法签名。
跨端方法名
| 操作 | Android | Web | Electron | macOS | Flutter | Native (C ABI) | iOS |
|---|---|---|---|---|---|---|---|
getUserProfile | getUserProfile | getUserProfile | getUserProfile | getUserProfile | getUserProfile | — | func |
updateMyUserProfile | updateMyUserProfile | updateMyUserProfile | updateMyUserProfile | updateMyUserProfile | updateMyUserProfile | — | func |
方法名在 GA 平台之间保持一致(规则 A);Native C ABI 只覆盖部分操作,其余操作以 — 标注。
getUserProfile
查询用户资料。
getUserProfile(userId: String, callback: ResultCallback<UserProfile>)参数
| 参数 | 类型 | 说明 |
|---|---|---|
userId | string | 必填;用户 ID |
返回
UserProfile 用户资料
示例
Kotlin
client.getUserProfile(
userId = "user2",
callback = object : ResultCallback<UserProfile> {
override fun onSuccess(result: UserProfile) { /* 处理返回数据 */ }
override fun onError(error: IMError) { /* 处理 error.code */ }
},
)错误码
| 错误码 | 名称 | 分类 | HTTP | 可重试 | 说明 |
|---|---|---|---|---|---|
1001 | INVALID_PARAMETER | 客户端 / 参数 / 权限 | 400 | 否 | 参数错误 |
1003 | FORBIDDEN | 客户端 / 参数 / 权限 | 403 | 否 | 无权限 |
1004 | USER_NOT_FOUND | 客户端 / 参数 / 权限 | 404 | 否 | 用户不存在 |
updateMyUserProfile
修改本人资料(name/avatarUrl)。
updateMyUserProfile(profile: UserProfileUpdate, callback: ResultCallback<UserProfile>)参数
| 参数 | 类型 | 说明 |
|---|---|---|
profile | {name?:string, avatarUrl?:string} | 必填;待更新的资料字段:{ name?:string, avatarUrl?:string } |
返回
UserProfile 用户资料
示例
Kotlin
client.updateMyUserProfile(
profile = UserProfileUpdate(),
callback = object : ResultCallback<UserProfile> {
override fun onSuccess(result: UserProfile) { /* 处理返回数据 */ }
override fun onError(error: IMError) { /* 处理 error.code */ }
},
)错误码
| 错误码 | 名称 | 分类 | HTTP | 可重试 | 说明 |
|---|---|---|---|---|---|
1001 | INVALID_PARAMETER | 客户端 / 参数 / 权限 | 400 | 否 | 参数错误 |
1003 | FORBIDDEN | 客户端 / 参数 / 权限 | 403 | 否 | 无权限 |
相关文档
- 功能列表:103 个操作与签名
- 状态码:错误码与重试策略
- API 参考:类与成员
- IMLib 集成指南