Created
July 27, 2020 20:06
-
-
Save cardoso/577768794a7f1a0af5c0df77ddf5d58d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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