![](/img/trans.png)
[英]Use of unresolved identifier 'FIRAuth' (Swift 2, Firebase 3.x)
[英]Undeclared Identifier FIRAuth
我是iOS和Fire Base的初学者。
firebase.h
在我loginViewcontroller.h
我正在从解析迁移到loginViewController.m
在我的loginViewController.m
添加了以下fire base身份验证代码。
[[FIRAuth auth] createUserWithEmail:email password:password completion:^(FIRUser *_Nullable user, NSError *_Nullable error) { // ... }];
但是它显示了一个错误,称为use of undeclared identifier FIRAuth
。 请帮忙。
您应该导入FirebaseAuth。
@import FirebaseAuth;
检查一下
1)窗格'Firebase / Auth'是否存在
2)在应用程序委托中,您是否使用以下方法进行配置
@import Firebase;
// Use Firebase library to configure APIs
[FIRApp configure];
试试这个,我希望它会有所帮助!但是它很快
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject : AnyObject]? = [:]) -> Bool {
UIApplication.shared.statusBarStyle = .lightContent
FIRApp.configure()
FIRDatabase.database().persistenceEnabled = true
return true
}
之后,您可以像这样使用它!
@IBAction func signUpDidTouch(_ sender: AnyObject)
{
let alert = UIAlertController(title: "Register",message: "Register",preferredStyle: .alert)
let saveAction = UIAlertAction(title: "Save",style: .default) { action in
let emailField = alert.textFields![0]
let passwordField = alert.textFields![1]
FIRAuth.auth()?.createUser(withEmail: emailField.text!, password: passwordField.text!, completion: { (user, error) in
if error == nil{
FIRAuth.auth()?.signIn(withEmail: self.textFieldLoginEmail.text!, password: self.textFieldLoginPassword.text!, completion: nil)
}
})
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.