2017-04-21 112 views
0

我是iOS和消防基礎的初學者。未聲明標識符FIRAuth

  • 我安裝了firebase可可豆莢。
  • loginViewcontroller.h
  • 新增莢 '火力地堡/核心', 莢 '火力地堡/數據庫', 莢 '火力地堡/驗證' 進口firebase.h

我正在從解析遷移到firebase,我在我的loginViewController.m中添加了以下防火牆驗證代碼。

[[FIRAuth auth] createUserWithEmail:email password:password completion:^(FIRUser *_Nullable user, NSError *_Nullable error) { // ... }];

但它顯示了一個錯誤稱爲use of undeclared identifier FIRAuth。 請幫忙。

+0

你能解釋一下你準備做什麼嗎? –

回答

2

檢查,

1)莢果 '火力地堡/驗證' 存在或不

2)在應用程序委託有您使用下面的方法

@import Firebase; 
// Use Firebase library to configure APIs 
[FIRApp configure]; 
0

嘗試此我希望配置這將是有幫助的!但它是在迅速

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) 
     } 
     }) 

    } 
2

您應該導入FirebaseAuth。

@import FirebaseAuth;