I have a question concerning adding multiple authentication methods to the iOS application.
Some authentication Systems (such as Facebook
and Google
) need to return boolean values in the method:
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:
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. Check out their implementation.