使用多个身份验证提供程序的Firebase电话身份验证

时间:2020-10-13 10:21:55

标签: ios swift firebase firebase-authentication

简介

我们一直无法使用配置有多个身份验证提供程序的Firebase Auth。

The documentation指定一个应用程序可以支持多个firebase项目。

电子邮件登录

我们已经能够成功配置我们的应用程序,以便电子邮件身份验证与多个身份验证提供程序一起使用。

例如:

// Configure secondary app
FirebaseApp.configure(name: "SecondaryAuth", options: options)

// Retrieve newly created app
guard let secondaryApp = FirebaseApp.app(name: "SecondaryAuth") else { return }

// Retrieve an Auth client configured against newly created app
let secondaryAuth = Auth.auth(app: secondaryApp)

因此,调用secondaryAuth.signIn(withEmail: …, password: …)成功并且可以正常工作。

电话登录

我们面临的问题电话身份验证有关。

我们注意到PhoneAuthProvider的初始化程序可以接受一个Auth参数,这使我们相信电话身份验证应该使用不同的身份验证提供程序。

The documentation指定要使电话身份验证正常工作,我们必须:

  • 在我们的Firebase项目中启用电话号码登录
  • 使用以下方式启用应用验证:
    • 静音推送通知
    • reCAPTCHA

我们已启用这些要求,并且我们的应用程序的Firebase项目均支持:

  • 电话号码登录
  • 具有正确配置的APNS
  • Xcode项目已正确配置URL方案

我们面临的问题是,在调用verifyPhoneNumber并通过传递PhoneAuthProvidersecondary auth之后,像这样: PhoneAuthProvider.provider(auth: secondaryAuth).verifyPhoneNumber(..., uiDelegate: nil)

我们收到以下错误消息: 'Please register custom URL scheme 'app-1-...' in the app's Info.plist file.'

请记住,我们已经为应用程序的info.plist中前面提到的secondaryApp指定了正确的URL方案。

0 个答案:

没有答案