[英]Managing multiple iOS authentication Firebase - Swift - Programmatically
I have a question concerning adding multiple authentication methods to the iOS application.我有一个关于向 iOS 应用程序添加多种身份验证方法的问题。
Some authentication Systems (such as Facebook
and Google
) need to return boolean values in the method:一些身份验证系统(例如Facebook
和Google
)需要在方法中返回布尔值:
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool
for Google I need to return:对于谷歌,我需要返回:
return GIDSignIn.sharedInstance()?.handle(url) ?? true
and for Facebook auth I need to return:对于 Facebook 身份验证,我需要返回:
return ApplicationDelegate.shared.application(app, open: url, options: options)
If I return one boolean, the other will never be called.如果我返回一个布尔值,另一个将永远不会被调用。
How can I check if the user is logging in with one particular method and return the right boolean?如何检查用户是否使用一种特定方法登录并返回正确的布尔值?
Try this:尝试这个:
if GIDSignIn.sharedInstance()?.handle(url) {
return true
}
else if ApplicationDelegate.shared.application(app, open: url, options: options) {
return true
}
return false
FirebaseUI follows a similar approach - it loops through all available / activated authentication providers, checking for each of them if it is able to handle the URL, and returning true
if that's the case. FirebaseUI 遵循类似的方法 - 它遍历所有可用/激活的身份验证提供程序,检查它们中的每一个是否能够处理 URL,如果是这种情况,则返回true
。 Check out their implementation .检查他们的实施。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.