Skip to content

Instantly share code, notes, and snippets.

@cardoso
Created July 27, 2020 20:04
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/5d182a8c86ccb2b8dc9690f3537aba1d to your computer and use it in GitHub Desktop.
Save cardoso/5d182a8c86ccb2b8dc9690f3537aba1d to your computer and use it in GitHub Desktop.
import StreamChat
import StreamChatClient
extension JoinViewController {
func setupHandlers() {
buyerButton.addTarget(self, action: #selector(handleBuyerButtonPress), for: .touchUpInside)
sellerButton.addTarget(self, action: #selector(handleSellerButtonPress), for: .touchUpInside)
}
@objc private func handleBuyerButtonPress() {
Client.shared.set(user: .init(id: .random()), token: .development) { result in
switch result {
case .success:
let buyerVC = BuyerViewController()
self.navigationController?.pushViewController(buyerVC, animated: true)
case .failure(let error):
print(error)
}
}
}
@objc private func handleSellerButtonPress() {
Client.shared.set(user: .init(id: "Seller"), token: .development) { result in
switch result {
case .success:
let channelsVC = ChannelsViewController()
channelsVC.title = "Messages"
channelsVC.presenter = .init(filter: .equal("type", to: "messaging"))
self.navigationController?.pushViewController(channelsVC, animated: true)
case .failure(let error):
print(error)
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment