简体   繁体   中英

How to set up Firebase iOS authentication email

Having looked through lots of previous questions and looking on the Firebase website documentation, it keeps leading me back to the snippet of code I need in my VC, BUT not how to actually set it up? .

Firstly in the email address verification setup on Firebase I've by mistake put my personal email address as the 'reply to' email - do I put my personal (not business) email in there/how would I change it? Apologies for any over the top censoring (not sure what is private and not) 在此处输入图片说明

Secondly in my SignUpViewController what do I put as the URL String and what do I put as my IOSBundleID ? Many thanks! 在此处输入图片说明

  1. To change the email go to Authentication and press templates. There you have some options for your mail.
  2. Press the pen beside noreply@yourfirebase.firebaseapp.com.

There you will have a replay to line and you can change all those settings

This is all you need to register a new user :

Auth.auth().createUser(withEmail: emailText.text!, password: passwordText.text!) { 
    (user, error) in
        if error != nil {
            print(error.localizedDescripton)
        }else {
            print("registration successful")
        }
    }

To send confirmation email to user make a call after user is created and use this method :

func sendConfirmationEmail() {
    // Here you check if user exist
    if self.authUser != nil && !self.authUser!.isEmailVerified {

        self.authUser!.sendEmailVerification(completion: { (error) in
            // Send the email
        })
    }
    else {
          // ERROR
    }
}

You could now call the second method after user been created and the user will get an email

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM