Handling different URL Schemes in iOS (Facebook and Instagram)

前端 未结 4 1711
陌清茗
陌清茗 2021-01-05 14:21

I am not even sure how to define the problem but here it goes.

I have an application that uses Facebook SDK for user login. I followed the Facebook authorization tut

4条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-05 14:52

    For Swift 2.0

    //MARK: FACEBOOK , GOOGLE CALLBACK URL METHOD
        //google-Firebase signin - IOS 8
        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 facebookDidHandle || googleDidHandle
        }
    
        //google-Firebase signin - IOS 9
        @available(iOS 9.0, *)
        func application(application: UIApplication,
                         openURL url: NSURL, options: [String: AnyObject]) -> Bool {
    
            let facebookDidHandle = FBSDKApplicationDelegate.sharedInstance().application(application, openURL: url, sourceApplication: options[UIApplicationOpenURLOptionsSourceApplicationKey] as! String, annotation: options[UIApplicationOpenURLOptionsAnnotationKey])
    
            let googleDidHandle = GIDSignIn.sharedInstance().handleURL(url, sourceApplication: options[UIApplicationOpenURLOptionsSourceApplicationKey] as! String, annotation: options[UIApplicationOpenURLOptionsAnnotationKey])
    
            return facebookDidHandle || googleDidHandle
        }
    

提交回复
热议问题