使用 firebase phone 身份验证创建用户?
Creating user using firebase phone authentication?
我正在使用 phone 登录身份验证(phone 号码和密码)并使用姓名、电子邮件、照片 url、地址 [=18] 等用户详细信息进行注册=] 号码和密码。通过使用注册 phone 号码字段请求 OTP 验证 phone 号码。在成功验证 phone 号码后,它会进入主页。
建议我使用 phone 号码注册创建用户,并使用 Cloud firestore
使用 OTP 请求进行验证
发送Otp用的就是这个方法。
手机号码必须带国家代码例如。 +1
PhoneAuthProvider.provider().verifyPhoneNumber(mobileNo, uiDelegate: nil) { (verificationID, error) in
if let error = error {
print(error)
APPDEL.window?.makeToast("Your mobile number is not valid")
complition(false)
return
}
UserDefaults.standard.set(verificationID, forKey: "authVerificationID")
complition(true)
// Sign in using the verificationID and the code sent to the user
}
并验证 OTP 并成功登录使用此
let verificationID = UserDefaults.standard.string(forKey: "authVerificationID")
let credential = PhoneAuthProvider.provider().credential(
withVerificationID: verificationID!,
verificationCode: verificationCode)
Auth.auth().signIn(with: credential) { (user, error) in
if let error = error {
print(error.localizedDescription)
APPDEL.window?.makeToast("OTP entered is incorrect")
complition(false)
return
}
complition(true)
}
我正在使用 phone 登录身份验证(phone 号码和密码)并使用姓名、电子邮件、照片 url、地址 [=18] 等用户详细信息进行注册=] 号码和密码。通过使用注册 phone 号码字段请求 OTP 验证 phone 号码。在成功验证 phone 号码后,它会进入主页。
建议我使用 phone 号码注册创建用户,并使用 Cloud firestore
使用 OTP 请求进行验证发送Otp用的就是这个方法。 手机号码必须带国家代码例如。 +1
PhoneAuthProvider.provider().verifyPhoneNumber(mobileNo, uiDelegate: nil) { (verificationID, error) in
if let error = error {
print(error)
APPDEL.window?.makeToast("Your mobile number is not valid")
complition(false)
return
}
UserDefaults.standard.set(verificationID, forKey: "authVerificationID")
complition(true)
// Sign in using the verificationID and the code sent to the user
}
并验证 OTP 并成功登录使用此
let verificationID = UserDefaults.standard.string(forKey: "authVerificationID")
let credential = PhoneAuthProvider.provider().credential(
withVerificationID: verificationID!,
verificationCode: verificationCode)
Auth.auth().signIn(with: credential) { (user, error) in
if let error = error {
print(error.localizedDescription)
APPDEL.window?.makeToast("OTP entered is incorrect")
complition(false)
return
}
complition(true)
}