簡體   English   中英

Firebase創建用戶Swift不起作用

[英]Firebase create user swift doesn't work

下面我剛剛鍵入的錯誤顯示“無法將類型'( )-> Void的值覆蓋到預期參數類型'(NSERROR!)-> Void!)”

在這行代碼上:怎么了?

FIREBASE_REF.createUser(email, password: password, withCompletionBlock: {(error,authData) -> Void in

@IBAction func creatAccountAction(sender: AnyObject) {
        let email = self.emailTextField.text
        let password = self.passwordTextField.text

        if email != "" && password != ""
        {
            FIREBASE_REF.createUser(email, password: password, withCompletionBlock: {(error,authData) -> Void in

            if error != nil {

                FIREBASE_REF.authUser(email, password: password, withCompletionBlock: { (error, authData) -> Void in

                    if error == nil {

                        NSUserDefaults.standardUserDefaults().setValue(authData.uid, forKey: "uid")
                    }
                    else {
                        print (error)
                    }
                })
            }
            else {
                print (error)
            }

            }

            )}

        else

嘗試這個:

FIREBASE_REF.createUser(email, password: password, withCompletionBlock: {(error) -> Void in

該塊可能只有一個參數

創建用戶有兩種選擇,一種是創建用戶,如果失敗則返回錯誤(withCompletionBlock),另一種還返回authData(withValueCompletionBlock):這就是您想要的。

myRootRef.createUser(email, password: pw, withValueCompletionBlock: { error, result in

            if error != nil {
                print("error creating user")
            } else {
                let uid = result["uid"] as! String
                NSUserDefaults.standardUserDefaults().setValue(uid, forKey: "uid")
                //pass the parameters to another function to auth the user
                self.authUserWithAuthData( email, password: pw ) 
            }

        })

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM