我正在将 ZDCChat 更新为 ChatSDK。我现在面临一个问题。
每次我来到聊天屏幕时,Chat.accountProvider?.observeAccount
这个观察者都会告诉我No Agent Available
。但是代理可以在我的浏览器上使用。
第二件事是当我输入消息并点击发送时,它没有显示在我的聊天屏幕上。
这是代码。这是在 AppDelegate 中:
let chatConfiguration = ChatConfiguration()
chatConfiguration.isPreChatFormEnabled = false
let chatAPIConfiguration = ChatAPIConfiguration()
chatAPIConfiguration.department = "Blah"
chatAPIConfiguration.visitorInfo = VisitorInfo(name: "BlahUser", email: "test@test.com", phoneNumber: "")
Chat.instance?.configuration = chatAPIConfiguration;
Chat.initialize(accountKey: "------my key------", queue: .main)
这就是我开始聊天的方式
let chatAPIConfiguration = ChatAPIConfiguration()
chatAPIConfiguration.department = "iOS App"
chatAPIConfiguration.visitorInfo = VisitorInfo(name: nameField.text!, email: emailField.text!, phoneNumber: "")
Chat.instance?.configuration = chatAPIConfiguration;
do {
let chatEngine = try ChatEngine.engine()
let viewController = try Messaging.instance.buildUI(engines: [chatEngine], configs: [])
viewController.view.backgroundColor = Constants.bgColor
self.navigationController?.pushViewController(viewController, animated: true)
} catch {
// handle error
print("error initaiting chat")
}
结束聊天也不起作用,我一直在开始会话。
let stateToken = Chat.chatProvider?.observeChatState { (state) in
// Handle logs, agent events, queue position changes and other events
print("My Session status: ", state.chatSessionStatus)
switch state.chatSessionStatus {
case .configuring:
print("COnfiguring")
case .ended:
print("Ended")
case .ending:
print("Ending")
case .initializing:
print("initializing")
case .started:
print("started")
default:
print("Default Case")
}
}