How to use both google+ and facebook login in same appdelegate.swift

前端 未结 3 2708
傲寒
傲寒 2020-12-02 23:41

My app use google+ signin and in my appdelegate.swift i have:

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSOb         


        
3条回答
  •  执笔经年
    2020-12-03 00:28

    Your application should handle facebook and google links, then return true if one or the other can handle the given link.

    func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool {
    
            let googleDidHandle = GIDSignIn.sharedInstance().handleURL(url,
                sourceApplication: sourceApplication,
                annotation: annotation)
    
            let facebookDidHandle = FBSDKApplicationDelegate.sharedInstance().application(
                application,
                openURL: url,
                sourceApplication: sourceApplication,
                annotation: annotation)
    
            return googleDidHandle || facebookDidHandle
    }
    

    And in didFinishLaunching :

    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
        // Override point for customization after application launch.
    
        var configureError: NSError?
        GGLContext.sharedInstance().configureWithError(&configureError)
        assert(configureError == nil, "Error configuring Google services: \(configureError)")
    
        GIDSignIn.sharedInstance().delegate = self
    
        return FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
    
    }
    

提交回复
热议问题