个人详情页
接入外部个人详情页
SDK 内置了用户个人详情页面, 可以通过实现 KIMUserProfileDelegate
协议, 替换成自己实现的个人详情页面。
接口定义
方法 | 参数 | 返回值 | 说明 |
---|---|---|---|
userProfileViewController | • userId: String 用户Id,该用户Id为SDK内部使用的用户Id, 需要与自身账户系统进行转换时可调用 KIM.userModule.getUserInfos 方法进行转换。 • params: KIMUserProfileParams 页面参数。 | UIViewController 个人详情页视图控制器。 | 该代理方法返回自定义的个人详情页视图控制器,如果开发者已实现自研的个人详情页面,并希望替换 SDK 内置的个人详情页,可以通过实现该方法返回自研的个人详情页面。当返回为nil时,内部走默认页面。 |
代码示例
swift
// 1. 实现协议。
class MyUserProfileProvider: KIMUserProfileDelegate {
func userProfileViewController(userId: String, params: KIMUserProfileParams) -> UIViewController? {
let vc = MyUserProfileSampleVC()
vc.userId = userId
return vc
}
}
// 2. 设置协议实现代理。
KIM.userModule.userProfileDelegate = MyUserProfileProvider()
1
2
3
4
5
6
7
8
9
10
11
12
2
3
4
5
6
7
8
9
10
11
12
Objective-C
// 1. 实现协议。
@interface MyUserProfileProvider ()<KIMUserProfileDelegate>
@end
@implementation MyUserProfileProvider
- (UIViewController *)userProfileViewControllerWithUserId:(NSString *)userId params:(KIMUserProfileParams *)params {
MyUserProfileSampleVC *vc = [[MyUserProfileSampleVC alloc] init];
vc.userId = userId
return vc;
}
@end
// 2. 设置协议实现代理。
KIM.userModule.userProfileDelegate = [[MyUserProfileProvider alloc] init];
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17