InAppChat iOS
为您的 iOS 应用带来愉悦的聊天体验
概览
此 SDK 通过 InAppChat 平台(https://inappchat.io)集成了一个完整的聊天体验。
安装
此 SDK 可通过传统方式作为 Cocoapod 访问
).package(url: "https://github.com/RipBullNetworks/inappchat-ios", .upToNextMajor(from: "1.0.0")),
CocoaPods
将pod添加到您的podfile中
pod "InAppChat"
使用方法
初始化SDK
在您的应用程序代理中,或者在其他您放置启动逻辑的地方,初始化InAppChat SDK
InAppChat.setup(apiKey: apiKey, delayLoad: true)
注意,您可以选择延迟加载,稍后调用InAppChat.shared.load
以在任何加载顺序中加载IAC
渲染UI
通过渲染InAppChatUI在任何视图中渲染应用程序内聊天,您可以包括任何
struct ContentView: View {
var body: some View {
InAppChatUI()
}
}
主题化
您可以通过将主题传递到InAppChatUI
来为主题化InAppChat UI套件。该主题支持字体、颜色以及类似气泡边框半径和图像大小等内容。向InAppChatUI提供Theme
。
struct ContentView: View {
var body: some View {
InAppChatUI(theme: Theme())
}
}
颜色
您可以向主题对象提供大量的参数来自定义自己的颜色主题。UI 工具包使用亮色和暗色主题,所以请提供两者。
struct ContentView: View {
var body: some View {
InAppChatUI(theme:
Theme(
light:
Colors(
primary: .blue,
background: .white
),
dark:
Colors(
primary: .blue,
background: .black
)
)
)
}
}
字体
UI 工具包使用与 iOS 相同的字体样式。您可以提供自己的字体对象来自定义这些字体。
struct ContentView: View {
var body: some View {
InAppChatUI(theme:
Theme(
fonts: Fonts(
title: .app(22, .black),
title2: .app(20, .heavy),
title2Regular: .app(20),
title3: .app(16, .heavy),
headline: .app(16, .bold),
body: .app(14),
caption: .app(12)
)
)
)
}
}
资源
您还可以在 UI 工具包中使用可自定义的资源以及文本。最重要的是为组使用默认图像。
struct ContentView: View {
var body: some View {
InAppChatUI(theme:
Theme(
assets: Assets(group: Image("my-group-placeholder"))
)
)
}
}
同时,也有空白屏幕配置。
struct ContentView: View {
var body: some View {
InAppChatUI(theme:
Theme(
emptyChannels: EmptyScreenConfig(
image: Image("empty-channels"),
caption: "You haven't joined any channels yet"),
emptyChat: EmptyScreenConfig(
image: Image("empty-chat"),
caption: "Your friends are ***dying*** to see you"
),
emptyThreads: EmptyScreenConfig(
image: Image("empty-threads"),
caption: "You haven't added to any threads yet"),
emptyAllChannels: EmptyScreenConfig(
image: Image("empty-all-channels"),
caption: "It's dead in here"
)
)
)
}
}
完!
所有内容版权所有 Rip Bull Networks, Inc