【发布时间】:2019-07-31 16:13:10
【问题描述】:
我在 Firebase 框架中使用标准用户名和密码。
登录 UI 曾经出现,但现在不再出现。
Google 签名 UI 仍然可以正常工作。
如下所示:
以前喜欢喜欢:
复制问题的代码如下:
import UIKit
import Firebase
import FirebaseUI
class ViewController: UIViewController {
private var handle: AuthStateDidChangeListenerHandle?
@IBOutlet weak var userLbl: UILabel!
@IBAction func logout(_ sender: Any) {
let firebaseAuth = Auth.auth()
do {
try firebaseAuth.signOut()
} catch let signoutError as NSError {
debugPrint("Error signing out: \(signoutError)")
}
}
override func viewDidLoad() {
super.viewDidLoad()
handle = Auth.auth().addStateDidChangeListener({ (auth, user) in
if user == nil {
if let authUI = FUIAuth.defaultAuthUI() {
authUI.delegate = self
let providers: [FUIAuthProvider] = [
FUIGoogleAuth()
]
authUI.providers = providers
let authViewController = authUI.authViewController()
self.present(authViewController, animated: true, completion: {})
}
}
else{
self.userLbl.text = user?.displayName
}
})
}
}
extension ViewController:FUIAuthDelegate{
func authUI(_ authUI: FUIAuth, didSignInWith authDataResult: AuthDataResult?, error: Error?){
if error != nil{
print("Error: \(error)")
return
}
self.userLbl.text = Auth.auth().currentUser?.displayName
}
}
PODS 是:
# Pods for FBTest
pod 'Firebase/Core'
pod 'Firebase/Firestore'
pod 'FirebaseUI'
pod 版本如下:
Using Bolts (1.9.0)
Using BoringSSL-GRPC (0.0.2)
Using FBSDKCoreKit (4.40.0)
Using FBSDKLoginKit (4.40.0)
Using Firebase (5.18.0)
Using FirebaseAnalytics (5.7.0)
Using FirebaseAuth (5.4.0)
Using FirebaseAuthInterop (1.0.0)
Using FirebaseCore (5.3.1)
Using FirebaseDatabase (5.1.0)
Using FirebaseFirestore (1.0.2)
Using FirebaseInstanceID (3.7.0)
Using FirebaseStorage (3.1.0)
Using FirebaseUI (6.1.1)
Using GTMSessionFetcher (1.2.1)
Using GoogleAppMeasurement (5.7.0)
Using GoogleSignIn (4.4.0)
Using GoogleToolboxForMac (2.2.0)
Using GoogleUtilities (5.3.7)
Using Protobuf (3.7.0)
Using SDWebImage (4.4.6)
Using TwitterCore (3.2.0)
Using TwitterKit (3.4.2)
Using gRPC-C++ (0.0.6)
Using gRPC-Core (1.17.0)
Using leveldb-library (1.20)
Using nanopb (0.3.901)
很好奇 google 身份验证是如何工作的,但股票标准身份验证已经停止工作。
【问题讨论】:
标签: swift firebase firebase-authentication firebaseui