Creating new user with firebase in Swift

后端 未结 4 1071
余生分开走
余生分开走 2021-01-15 17:36

I am new to Firebase and have been trying to implement a \"Sign Up\" page for my app. Currently, I am only using the email feature, just to test things out. I am able to cre

4条回答
  •  攒了一身酷
    2021-01-15 18:09

    Swift 4.1 FireBase User Create/Login Steps:-

    STEP 1:- Register new firebase authentication Pod in to your Podfile :

    pod 'Firebase/Auth'
    

    STEP 2:- Open terminal and install pod with your related project directory path:

    pod install
    

    STEP 3:- import firebase authentication library in your UIViewController where ever you want:

    import FirebaseAuth
    

    STEP 4:- On your Registration UIButton Action write this snippet :

     Auth.auth().createUser(withEmail: (txtEmail.text ?? ""), password: (txtPass.text ?? "")) { (result, error) in
                if let _eror = error {
                    //something bad happning
                    print(_eror.localizedDescription )
                }else{
                    //user registered successfully
                    print(result)
                }
             }
    

    STEP 5:- If you want to Sign In after Registration use this snippet on your Sign in UIButton:

      Auth.auth().signIn(withEmail: (txtEmail.text ?? ""), password: (txtPass.text ?? "")) { (result, error) in
                if let _eror = error{
                    print(_eror.localizedDescription)
                }else{
                    if let _res = result{
                        print(_res)
                    }
                }
            }
    

    Happy Codding ;)!!!!

提交回复
热议问题