简介
我们一直无法使用配置有多个身份验证提供程序的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项目均支持:
我们面临的问题是,在调用verifyPhoneNumber
并通过传递PhoneAuthProvider
和secondary 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方案。