ZowieSDK 0.0.20

ZowieSDK 0.0.20

Szymon WojcikMaciej CiołekPrzemyslaw Skiba 维护。



 
依赖于
Apollo~> 0.49.1
Apollo/WebSocket~> 0.49.1
Kingfisher~> 7.0
lottie-ios= 4.4.1
 

ZowieSDK 0.0.20

  • Zowie

Zowie iOS SDK

Swift 5.3 Supported Swift 5.3 Supported

安装

Cocoapods

在您的 Podfile 中添加 pod ZowieSDK

pod ZowieSDK

为了支持 Zowie 使用的依赖项,请将以下代码添加到您的 Podfile 结尾处

post_install do |installer|
  installer.pods_project.targets.each do |target|
    if ["Apollo", "Apollo/WebSocket", "Kingfisher", "lottie-ios"].include? target.name
      target.build_configurations.each do |config|
        config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'
      end
    end
  end
end

使用说明

初始化

要使用Zowie SDK,首先需要提供配置

let configuration = ZowieConfiguration(
    instanceId: "INSTANCEID",
    authType: .anonymous
)

Zowie.shared.set(configuration: configuration)

*请记住,没有适当的配置设置,您将无法使用SDK的任何功能,所以请确保您提供它。**

您可以使用Zowie.shared.clearAnonymousSession(forInstanceId: "INSTANCEID")清除匿名会话。如果您的集成需要token认证,请将.anonymous替换为.token

聊天用户界面

您可以通过ZowieChatViewController访问聊天用户界面。就像使用常规视图控制器一样,因此您可以将它放入您的堆叠中。例如,您可以从不同的视图控制器显示它

let chatViewController = ZowieChatViewController()
navigationController?.pushViewController(chatViewController, animated: true)

聊天初始化错误

如果您想处理聊天初始化错误,请使用

Zowie.shared.onChatInitializationError = { error in
    // Do someting
}

设置用户元数据

您可以设置所需用户元数据。所有这些字段都是可选的。

let metadata = ZowieMetadata(
    firstName: "first",
    lastName: "last",
    name: "name",
    locale: "locale",
    timeZone: "timeZone",
    phoneNumber: "123456789",
    email: "[email protected]",
    extraParams: ["custom": "value"]
)
Zowie.shared.set(metadata: metadata)

FCM通知

为了接收FCM通知,您必须提供deviceToken

Zowie.shared.set(fcmToken: "token") { result in
    // Completion handler is optional
}

这允许我们向用户的设备发送推送通知。请记住,您已设置所有必需的通知相关权限。

如果您想禁用通知,请使用

Zowie.shared.disableNotifications() { result in
    // Completion handler is optional
}

上下文

您可以通过向后端提供contextId来进行输入。

Zowie.shared.set(contextId: "contextId") { result in
    // Completion handler is optional
}

自定义

布局

let config = ZowieLayoutConfiguration(showConsultantAvatar: false, consultantNameMode: .firstName)
Zowie.shared.set(layoutConfiguration: config)

本地化

本SDK只支持英语。如需更多本地化,请提供以下内容

let strings = ZowieStrings(
    messagePlaceholder: "string",
    sendFailureErrorMessage: "string",
    tryAgain: "string",
    delivered: "string",
    read: "string",
    attachment: "string",
    disconnectMessage: "string",
    reconnectMessage: "string",
    historyErrorMessage: "string"
)

Zowie.shared.set(strings: strings)

颜色

您可以使用Zowie.shared.set(colors: colors)帮助设置自己喜欢的颜色品牌

URL处理

默认情况下,Zowie SDK使用外部网络浏览器打开URL。您可提供自定义处理

Zowie.shared.set(urlHandler: { url, source in
    // Return false if you want to handle URL by yourself
    return false
})