2016-06-22 6 views
3

나는 firebase와 함께 새로운 작업을하고 있으며 firebase를 사용하는 응용 프로그램의 로그인과 등록 창을 만들고 있습니다. 당신은 당신이 거기 그 버튼을 클릭하여 새 계정을 생성하고 싶은 경우 This is what the login code looks likefirebase에 새 사용자 등록

하지만이 소요됩니다 내가 콘솔에서 계정을 만든로

현재 로그는 오랫동안 나를 위해 잘 작동 새의 ViewController 창으로, 거기에 내가 계정을 새로 만들 채우기 위해 일을 추가하고 난 여기에 코드가 picture of the code and the imageview

처럼 보이는 방법의 사진을
FIRAuth.auth()?.createUserWithEmail(<email: String>, password: <String>, completion: <FIRAuthResultCallback?(FIRUser?, NSError?) -> Void#>) 

을 사용

새 사용자를 등록하려고 할 때 작동하지 않는 메시지가 표시되고 새 사용자를 생성하지 않는 이유를 모르겠습니다.

보너스 질문 내가 어떻게 작동합니까? 그 창문에서 다른 창으로 간다?

답변

3

이 작동합니다 :

var ref: FIRDatabaseReference! 


override func viewDidLoad() { 
    super.viewDidLoad() 

    ref = FIRDatabase.database().reference() 
    // Do any additional setup after loading the view. 
} 


@IBAction func signup(sender: AnyObject) { 
    if let em = email.text, pass = password.text{ 
     FIRAuth.auth()?.createUserWithEmail(email.text!, password: password.text!) {(user, error) in 
      if let error = error { 
       print(error.localizedDescription) 
      } 
      else { 
       print("User signed in!") 

       self.ref.child("data/users").updateChildValues(["\(FIRAuth.auth()!.currentUser!.uid)":["Username":self.username.text!]]) 

       self.performSegueWithIdentifier("home", sender: self) 
       //At this point, the user will be taken to the next screen 
      } 
     } } 
    else{ 
     print("You left email/password empty") 
    } 
} 

를했는지 확인 설치 한 중포 기지, FirebaseAuth 및 FirebaseDatabase (당신이 cocoapods를 사용하는 경우, 귀하의 포드는 아래와 같이한다)

pod 'Firebase' 
pod 'Firebase/Auth' 
pod 'Firebase/Database' 
+0

모두 이 'Value of type'RegisterViewController '멤버'ref '가 없습니다. 내가 심판에 다른 것을 써야 할까? 죄송합니다 나는 이것에 대한 새로운 작업입니다 – Manu

+0

나는 내 대답을 업데이트했습니다 : –

+0

그것은 일했습니다!, 정말 고마워요! – Manu