简体   繁体   English

如何设置Firebase iOS身份验证电子邮件

[英]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? 在浏览了许多先前的问题并查看了Firebase网站文档之后,它使我重新回到了我在VC中所需的代码片段,但不是如何实际设置它? .

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? 首先, 在Firebase上电子邮件地址验证设置中,我误将我的个人电子邮件地址作为“回复”电子邮件-我是否将我的个人(非商业)电子邮件放在其中/如何更改? 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 ? 其次,在我的SignUpViewController中 ,我应该把什么作为URL String ,我应该把什么作为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. 在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 现在,您可以在创建用户后调用第二种方法,该用户将收到一封电子邮件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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