-
-
Save zontan/04e6a54072fc2a578275b70ea0ae88cd 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 handle: AuthStateDidChangeListenerHandle? | |
var userName: String? | |
var channelName = "default" | |
override func viewDidAppear(_ animated: Bool) { | |
handle = Auth.auth().addStateDidChangeListener { (auth, user) in | |
if user == nil { | |
self.navigationController?.popToRootViewController(animated: true) | |
} else { | |
self.userName = user?.displayName | |
} | |
} | |
joinChannel() | |
} | |
override func viewWillDisappear(_ animated: Bool) { | |
leaveChannel() | |
if let handle = handle { | |
Auth.auth().removeStateDidChangeListener(handle) | |
} | |
} | |
func setUserName(name: String?) { | |
userName = name | |
if let name = name { | |
getAgoraEngine().registerLocalUserAccount(name, appId: appID) | |
} | |
} | |
func setChannelName(channel: String) { | |
channelName = channel | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment