Skip to content

Instantly share code, notes, and snippets.

@zontan
Last active July 6, 2020 17:47
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 zontan/bb0ff85f49518e5697a3de0f9ef188ab to your computer and use it in GitHub Desktop.
Save zontan/bb0ff85f49518e5697a3de0f9ef188ab to your computer and use it in GitHub Desktop.
var inCall = false
let tempToken: String? = nil //If you have a token, put it here.
var callID: UInt = 0 //This tells Agora to generate an id for you. We have user IDs from Firebase, but they aren't Ints, and therefore won't work with Agora.
var channelName: String?
override func viewWillAppear(_ animated: Bool) {
handle = Auth.auth().addStateDidChangeListener { (auth, user) in
self.currentUser = user
if user == nil {
self.showFUIAuthScreen()
} else {
self.joinChannel(channelName: user!.uid)
}
}
}
func joinChannel(channelName: String) {
getAgoraEngine().joinChannel(byToken: tempToken, channelId: channelName, info: nil, uid: callID) { [weak self] (sid, uid, elapsed) in
self?.inCall = true
self?.callID = uid
self?.channelName = channelName
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment