Skip to content

Instantly share code, notes, and snippets.

@cardoso
Last active June 11, 2020 01:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cardoso/e27c1e0f059fe75b568311a1027edf85 to your computer and use it in GitHub Desktop.
Save cardoso/e27c1e0f059fe75b568311a1027edf85 to your computer and use it in GitHub Desktop.
import StreamChat
import StreamChatClient
extension UserViewController {
func setupHandlers() {
supportButton.target = self
supportButton.action = #selector(handleSupportButtonPress)
}
@objc func handleSupportButtonPress() {
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: "Agent")) { _ in
}
}
let chatVC = ChatViewController()
chatVC.presenter = .init(channel: channel)
chatVC.title = "Support"
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