-
-
Save zontan/6c53dbf89558fb4bf9ced995e6ff767c 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
var agoraRtm: AgoraRtmKit? | |
override func viewDidLoad() { | |
... | |
agoraRtm = AgoraRtmKit.init(appId: appID, delegate: self) | |
} | |
override func viewWillAppear(_ animated: Bool) { | |
handle = Auth.auth().addStateDidChangeListener { (auth, user) in | |
self.currentUser = user | |
if let user = user { | |
self.joinChannel(channelName: user.uid) | |
self.agoraRtm?.login(byToken: nil, user: user.displayName ?? user.uid) { (error) in | |
if (error != .ok) { | |
print("Failed to login to RTM: ", error.rawValue) | |
} | |
} | |
} else { | |
self.agoraRtm?.logout(completion: nil) | |
self.showFUIAuthScreen() | |
} | |
} | |
} | |
... | |
extension AgoraVideoViewController: AgoraRtmDelegate { | |
func rtmKit(_ kit: AgoraRtmKit, connectionStateChanged state: AgoraRtmConnectionState, reason: AgoraRtmConnectionChangeReason) { | |
if state == .connected { | |
chatButton.isEnabled = true | |
} else { | |
chatButton.isEnabled = false | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment