2017-06-15 23 views
0

私は数日間この問題に苦労しています。私は新人ですし、解決策を見つけることができません。 XCode 8.3.3を使用してユーザー登録とログインページを作成しようとしており、Firebaseをデータベースとして使用しています。次のようにFirebase認証を使用できません:FIRAuth.authは機能しません

私のコードは次のとおりです。

import UIKit 
import Firebase 
import FirebaseAuth 

class SignUpViewController: UIViewController { 

    //Outlets 
    @IBOutlet weak var emailTextField: UITextField! 
    @IBOutlet weak var passwordTextField: UITextField! 

    //Sign Up Action for email 
    @IBAction func createAccountAction(_ sender: AnyObject) { 

     if emailTextField.text == "" { 
      let alertController = UIAlertController(title: "Error", message: "Please enter your email and password", preferredStyle: .alert) 

      let defaultAction = UIAlertAction(title: "OK", style: .cancel, handler: nil) 
      alertController.addAction(defaultAction) 

      present(alertController, animated: true, completion: nil) 
     } else { 
      FIRAuth.auth().createUser(withEmail: emailTextField.text!, password: passwordTextField.text!) { (user, error) in 

      if error == nil { 
       print("You have successfully signed up") 
       //Goes to the Setup page which lets the user take a photo for their profile picture and also chose a username 

       let vc = self.storyboard?.instantiateViewController(withIdentifier: "Home") 
       self.present(vc!, animated: true, completion: nil) 

      } else { 
       let alertController = UIAlertController(title: "Error", message: error?.localizedDescription, preferredStyle: .alert) 

       let defaultAction = UIAlertAction(title: "OK", style: .cancel, handler: nil) 
       alertController.addAction(defaultAction) 

       self.present(alertController, animated: true, completion: nil) 
      } 
     } 
    } 
} 

問題がFIRAuth.authであり一部。エラーは「FIRAuthがAuthに改名されました」と書かれていますが、このような修正を適用すると、ビルドは成功しましたが、白い画面だけしか見ることができませんでした。コードを削除すると、前に作成した通常のサインイン画面が表示されます。

もう1つは、FirebaseAuthと入力したときに、FirebaseAuthを抜けた推奨単語リストに赤い線が現れましたが、それでも進行しました。

助けてください。私はなぜそれが起こるのか分からない。欠けているPodファイルがありますか?とても有難い。

絵コンテ: storyboard

+0

AppDelegateでFirebaseを設定しましたか? – PGDev

+0

インポートFirebaseAuthを削除してみてください。 – PGDev

+0

ポッドをFirebase SDK 4.0にアップデート –

答えて

4

FIRAuthは最後FirebaseバージョンでAuthになりました。

// Use Firebase library to configure APIs 
FirebaseApp.configure() 

は今、あなたは(もimport Firebaseを)あなたのファイルで使用することができます

Auth.auth().createUser(withEmail: email, password: password) { (user, error) in 
    // ... 
} 

はそれが

のホープ: link to Docs

import Firebase 

その後、application:didFinishLaunchingWithOptions:方法では、FirebaseAppオブジェクトを初期化します

+0

私は、ビルドは成功しました。しかし、私は最初のサインアップ画面ではなく、白い画面を持っています –

+0

@AndrewQinはあなたにrootviewcontrollerをインストールしましたか? (?:のUIApplication、didFinishLaunchingWithOptionsのlaunchOptions:[UIApplicationLaunchOptionsKey:任意] _アプリケーション) –

+0

関数funcアプリケーションでアプリケーションデリゲートではナビゲーションの流れ –

関連する問題