Skip to content

Instantly share code, notes, and snippets.

@cardoso
Created July 27, 2020 20:06
Show Gist options
  • Save cardoso/577768794a7f1a0af5c0df77ddf5d58d to your computer and use it in GitHub Desktop.
Save cardoso/577768794a7f1a0af5c0df77ddf5d58d to your computer and use it in GitHub Desktop.
import StreamChat
import StreamChatClient
extension BuyerViewController {
func setupHandlers() {
chatButton.target = self
chatButton.action = #selector(handleChatButtonPress)
}
@objc func handleChatButtonPress() {
let uid = Client.shared.user.id
let channel = Client.shared.channel(type: .messaging, id: "support-\(uid)")
channel.extraData = ChannelExtraData(name: "\(uid) support")
channel.create { _ in
channel.add(user: .init(id: "Seller")) { _ in
}
}
let chatVC = ChatViewController()
chatVC.presenter = .init(channel: channel)
chatVC.title = "Messages"
let navigation = UINavigationController(rootViewController: chatVC)
self.present(navigation, animated: true, completion: {
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment