我正在尝试创建一个按钮,让用户匿名登录到 Firebase,接收回调,然后如果登录成功则过渡到下一个 ViewController。对编程非常陌生,因此非常感谢您的帮助:
import UIKit
import FirebaseAuth
class ViewController: UIViewController {
@IBAction func Auth(_ sender: Any) {
FIRAuth.auth()?.signInAnonymously(completion: <#T##FIRAuthResultCallback?##FIRAuthResultCallback?##(FIRUser?, Error?) -> Void#>)
//Receive callback showing completion or error, then navigate to next ViewController
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
最佳答案
希望对您有所帮助。 :)
import UIKit
import FirebaseAuth
class ViewController: UIViewController {
@IBAction func Auth(_ sender: Any) {
FIRAuth.auth()?.signInAnonymously { (user, error) in
if let error = error {
print("Sign in failed:", error.localizedDescription)
} else {
print ("Signed in with uid:", user!.uid)
}
}
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
关于ios - 无法实现 Firebase 匿名身份验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42615503/