2017-02-12 4 views
0

私はコーディングに新しいので、これに対する答えが明らかであればごめんなさい。アプリケーションの初期化エラーに[FIRApp configure]を追加してください

自分のアプリをFirebaseサーバーに同期しようとしましたが、私はココアポッドをインストールしてGoogleService情報plistを追加しました。私は、新しいユーザーを作成しようとすると、しかし、私はエラーを取得する:私は、ユーザー

import UIKit 
import Firebase 
import FirebaseAuth 

class signUpViewController: UIViewController { 



    @IBOutlet var fullNameTextField: UITextField? 
    @IBOutlet var contactNumberTextField: UITextField? 
    @IBOutlet var emailTextField: UITextField? 
    @IBOutlet var passwordTextField: UITextField? 
    @IBOutlet var dateOfBirth: UIDatePicker? 


    func createMyAlert(title: String, message: String) { 

     let alarm = UIAlertController(title: title, message: message, preferredStyle: UIAlertControllerStyle.alert) 
     alarm.addAction(UIAlertAction(title: "ok", style: .default, handler: { (ACTION) -> Void 
      in self.dismiss(animated: true, completion: nil) 

     })) 

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

    @IBAction func continueButtonPressed(_ sender: Any) { 

     if fullNameTextField?.text == "" || contactNumberTextField?.text == "" || emailTextField?.text == "" || passwordTextField?.text == "" { 

      createMyAlert(title: "Error", message: "Please complete all fieds") 

     } else { 

     // This will create a new user 
      FIRAuth.auth()?.createUser(withEmail: (self.emailTextField?.text!)!, password: (self.passwordTextField?.text!)!) { (user, error) in 


     // this code will check the user isnt nil 

       if let u = user { 

        self.performSegue(withIdentifier: "createProfile", sender: self) 

       } 
       else 
       { 

        self.createMyAlert(title: "Oops", message: "Error") 

       } 
      } 

     } 
    } 

} 
+0

は、スタックオーバーフローを歓迎する代わり

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> ObjCBool { 

で以下のように股​​関節でinitメソッドとcconfigureのfireappを上書きするようにしてくださいを設定します。私は成功してコードをフォーマットしようとしましたが、コードをできるだけ明確にするために時間をかけてください。 – GabrielOshiro

答えて

0

を登録に使用しています

The default Firebase app has not yet been configured. Add [FIRApp configure] to your application initialization

アプリの委任

import UIKit 
import Firebase 


@UIApplicationMain 
class AppDelegate: UIResponder, UIApplicationDelegate { 

    var window: UIWindow? 

    private func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> ObjCBool { 

     FIRApp.configure() 

     return true 
    } 

コードの呼び出しのように見えますFIRApp.configure()は実際にデータベースにアクセスしようとする前に実行されていません。詳細についてのリンク以下

override init() { 
super.init() 
FIRApp.configure() 
// not really needed unless you really need it  FIRDatabase.database().persistenceEnabled = true 
} 

チェック:

The default app has not been configured yet

関連する問題