Displaying Chat
Setting User
Before opening chat, user setup is a mandatory step:
let chatUser = ChatUser(identifier: "Identifier", name: "Name")
chatCenterSDK.authorize(user: chatUser)
Identifier must be unique, permanent, and resistant to guessing — avoid using phone numbers, emails, and other identifiers that uniquely identify the user. If unavoidable, strictly apply RSA encryption.
For questions, contact support@edna.ru
Opening Chat
To get chat controller, use getChat method on SDK instance:
chatCenterSDK.getChat()
To handle possible SDK lifecycle errors, this method can throw an exception, full code with handling:
let result = Result { try chatCenterSDK.getChat() }
switch result {
case let .success(chatController):
// Open chat screen in UINavigationController
navigationController?.pushViewController(chatController, animated: true)
case let .failure(error):
// Error handling (e.g., user not set)
print("error: \(error)")
}
The obtained UIViewController class instance can be used in the application to display chat screen.
This can be done in UINavigationController/UITabBarController containers or without.
But keep in mind that navigation elements in chat are used from parent container.
That is, by default it's recommended to use your UINavigationController or create one for chat screen.