I am updating ZDCChat to ChatSDK. I am facing an issue right now.
Every time I come to chat screen Chat.accountProvider?.observeAccount
this observer tells me that No Agent Available
. But agent is available with me on my browser.
Second thing is when I enter a message and hit send , it's not showing on my chat screen.
Here is the code. This is in 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)
This is how I am starting the chat
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")
}
End chat is also not working, I am keep getting the Session Started.
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")
}
}