Created
July 27, 2020 20:04
-
-
Save cardoso/5d182a8c86ccb2b8dc9690f3537aba1d 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 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