集成应用容器界面
协作中台 SDK 提供了网页应用容器,容器功能如下:
- 协作中台提供基于 H5 开发的网页应用,支持将企业内已有的H5 应用快速迁移到工作台中。
效果展示

可以通过两种方式集成应用容器页面:
- 直接使用
KIMWebAppViewController
类,集成默认的应用容器界面。 - 继承使用
KIMWebAppViewController
类,通过实现协议自定义应用容器界面。
接口定义
swift
public init(appId: String, urlString: String? = nil, isSubPage: Bool = false)
Objective-C
- (instancetype)initWithAppId:(NSString *)appId;
参数说明
参数 | 类型 | 说明 |
---|---|---|
appId | String? | 应用的appId |
urlString | String? | 加载链接,不传则加载应用首页。 |
isSubPage | Bool | 是否为子页面(指的是基于当前应用容器通过js打开新的容器场景) |
代码示例
- 直接使用
KIMWebAppViewController
。
swift
let controller = KIMWebAppViewController(appId: "appId")
self.navigationController.pushViewController(controller, animated: true)
Objective-C
KIMWebAppViewController *controller = [[KIMWebAppViewController alloc] initWithAppId:@"appId"];
[self.navigationController pushViewController:controller animated:YES];
- 继承使用
KIMWebAppViewController
。
swift
// 1. 继承自应用容器视图控制器。
class CustomWebAppViewController: KIMWebAppViewController, KIMWebAppViewControllerDelegate {
// 2. 重写初始化方法,设置页面自定义协议代理。
required init(app: KIMAppBrief, urlString: String? = nil, isSubPage: Bool = false) {
super.init(app: app, urlString: urlString, isSubPage: isSubPage)
self.delegate = self
}
required init(appId: String, urlString: String? = nil, isSubPage: Bool = false) {
super.init(appId: appId, urlString: urlString, isSubPage: isSubPage)
self.delegate = self
}
required init?(coder _: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
required init?(with data: Data) {
super.init(with: data)
self.delegate = self
}
override func viewDidLoad() {
super.viewDidLoad()
}
// 3. 实现页面自定义协议方法。
func webAppViewController(_ controller: KIMWebAppViewController, configTitleView titleView: KIMNavigationTitleView) {
// 实现标题栏配置方法完成标题栏样式自定义。
}
// ...
}
// 4. 使用自定义的视图控制器。
let controller = CustomWebAppViewController()
self.navigationController.pushViewController(controller, animated: true)
// 5. 如果需要SDK内部全局替换成自定义的子类(如 CustomWebAppViewController),可注册子类类型。
KIM.workSpaceModule.webAppViewControllerType = CustomWebAppViewController.self