Last active
June 11, 2020 01:34
-
-
Save cardoso/aeb496435868fe11756b5e6c2a0a6c0e 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() { | |
userButton.addTarget(self, action: #selector(handleUserButtonPress), for: .touchUpInside) | |
agentButton.addTarget(self, action: #selector(handleAgentButtonPress), for: .touchUpInside) | |
} | |
@objc private func handleUserButtonPress() { | |
Client.shared.set(user: .init(id: .random()), token: .development) { result in | |
switch result { | |
case .success: | |
let userVC = UserViewController() | |
self.navigationController?.pushViewController(userVC, animated: true) | |
case .failure(let error): | |
print(error) | |
} | |
} | |
} | |
@objc private func handleAgentButtonPress() { | |
Client.shared.set(user: .init(id: "Agent"), token: .development) { result in | |
switch result { | |
case .success: | |
let channelsVC = ChannelsViewController() | |
channelsVC.title = "Support Queue" | |
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