Created
October 9, 2021 06:08
-
-
Save fredriccliver/578b48323cd5ccd65c46c911610c6eed 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 UIKit | |
import FirebaseAuth | |
import Kingfisher | |
class NextVC: UIViewController { | |
@IBOutlet var profileImageView: UIImageView! | |
@IBOutlet var nameLabel: UILabel! | |
@IBAction func onLogoutButton(_ sender: UIButton) { | |
do{ | |
try Auth.auth().signOut() | |
self.dismiss(animated: true, completion: nil) | |
}catch let err as NSError { | |
print(err) | |
} | |
} | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
presentUserInfo() | |
} | |
func presentUserInfo(){ | |
guard let user = Auth.auth().currentUser else { | |
print("user not logged in") | |
return | |
} | |
// print(user.isAnonymous) | |
/* | |
displayName | |
photoURL | |
isAnonymous | |
*/ | |
profileImageView.kf.setImage(with: user.photoURL, placeholder: nil, options: nil) { result, error in | |
} | |
if(user.isAnonymous){ | |
nameLabel.text = "Anonymous" | |
}else{ | |
nameLabel.text = user.displayName | |
} | |
} | |
@IBAction func touchedLogoutButton(_ sender: UIButton) { | |
do { | |
try Auth.auth().signOut() | |
dismiss(animated: true, completion: nil) | |
} catch let signOutError as NSError { | |
print("Error signing out: %@", signOutError) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment