firebase FIRUser.sendEmailVerificationWithCompletion(FIRUser) 函数的示例 swift IOS

An Example of the firebase FIRUser.sendEmailVerificationWithCompletion(FIRUser) function swift IOS

http://cocoadocs.org/docsets/FirebaseAuth/3.0.2/Classes/FIRUser.html#//api/name/sendEmailVerificationWithCompletion:

https://firebase.google.com/docs/reference/ios/firebaseauth/interface_f_i_r_user#method-detail

谁能举例说明如何使用此功能? 对于在括号内输入的内容,我将不胜感激。 这些链接对此功能做了一些解释。

如您在文档中所见,回调是可选。这是一个将在电子邮件验证完成后立即调用的函数。所以你应该使用这个参数在验证完成后调用你想要的任何逻辑。

在以下示例中,验证在 IBAction 中调用,完成后测试是否发生任何错误。

@IBAction func didRequestVerifyEmail(sender: AnyObject) {
     FIRAuth.auth()?.currentUser?.sendEmailVerificationWithCompletion({ (error) in
          if let error = error {
            print(error.localizedDescription)
            return
          }
          print("Sent")
     })
}