2016-06-28 63 views
2

通過關注this link的信息,我正在嘗試使用Firebase創建用戶,如下面的代碼所示。但是,應用程序運行時似乎沒有用戶被創建。任何輸入是不勝感激。 Firebase網址取自我的測試數據庫。添加Firebase用戶時出錯Swift

let ref = Firebase(url: "https://test-96df2.firebaseio.com") 
    ref.createUser("[email protected]", password: "correcthorsebatterystaple", 
        withValueCompletionBlock: { error, result in 
        if error != nil { 
         // There was an error creating the account 
         print("error creating account") 
        } else { 
         let uid = result["uid"] as? String 
         print("Successfully created user account with uid: \(uid)") 
        } 
    }) 

編輯

的傳播錯誤是:

錯誤代碼:AUTHENTICATION_DISABLED)在 創建的項目console.firebase.google.com必須使用新的火力地堡認證 的SDK可從firebase.google.com/docs/auth/獲得。

但是,如下所示,Firebase控制檯中啓用了電子郵件/密碼身份驗證。 enter image description here

+1

調試它並查看'error'對象。它應該有更多關於錯誤的細節。 – adolfosrs

+0

你正在使用什麼'firebase'版本? – adolfosrs

+0

我不完全確定我正在使用哪個版本的Firebase,但我相信最新的一個。 – sBourne

回答

2

您已經授權電子郵件註冊,因爲我可以在屏幕截圖中看到。所以這個問題不能在AUTHENTICATION_DISABLED上實現。

從您的錯誤消息和代碼段代碼中,我可以看到您已創建新項目,但您嘗試使用舊版的Firebase SDK,因此您將遇到兼容性問題。此外,您正在查看舊的Firebase文檔。

首先,您需要確保您已配置項目,如new firebase start guide中所述。你可以看看documentation for creating a new user與新的SDK。您可以找到3.x創建用戶調用波紋管。

FIRAuth.auth()?.createUserWithEmail(email, password: password) { (user, error) in 
    // ... 
} 
+0

謝謝,工作起來像一個魅力。 – sBourne