Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Integrating Google and Facebook login in iOS - AppDelegate openURL

Tags:

xcode

ios

I'm trying to integrate facebook and google login into my app but having a problem: Both require the following to be added into the openURL method in the Appdelegate:

return [GIDSignIn sharedInstance] handleURL:url
                           sourceApplication:sourceApplication
                                         annotation:annotation]];

return [FBSDKApplicationDelegate sharedInstance] application:application
                                                       openURL:url
                                             sourceApplication:sourceApplication
                                                    annotation:annotation
         ]]

Is there anyway of having these both work together properly. I've looked online but the answers are quite vague and fail to provide a good explanation

Solution

Added the following which did the trick for me (as of iOS 9):

return [[GIDSignIn sharedInstance] handleURL:url sourceApplication:sourceApplication annotation:annotation] || [[FBSDKApplicationDelegate sharedInstance] application:application openURL:url sourceApplication:sourceApplication annotation:annotation ];
like image 475
user1686342 Avatar asked Oct 12 '15 16:10

user1686342


1 Answers

Updated Answer

func application(
            _ app: UIApplication,
            open url: URL,
            options: [UIApplication.OpenURLOptionsKey : Any] = [:]
        ) -> Bool {

        let urlString = url.absoluteString
        if urlString.contains("fb"){
            ApplicationDelegate.shared.application(
                app,
                open: url,
                sourceApplication: options[UIApplication.OpenURLOptionsKey.sourceApplication] as? String,
                annotation: options[UIApplication.OpenURLOptionsKey.annotation]
            )
        }
        else{
            
        }
            return GIDSignIn.sharedInstance().handle(url)
        }
like image 163
shashi Gupta Avatar answered Oct 03 '22 19:10

shashi Gupta