Handling openURL: with Facebook and Google

后端 未结 10 1674
长情又很酷
长情又很酷 2021-01-01 09:39

user in my app can login using 2 services : Facebook or Google

everything works fine, however, in the :

- (BOOL)application:(UIApplication *)applicat         


        
10条回答
  •  醉酒成梦
    2021-01-01 10:31

    You can just let either Google SDK or Facebook SDK attempt handling and if the SDK does not handle then allow the other SDK to try:

        @available(iOS 9.0, *)
    private func application(_ application: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any])
        -> Bool {
            let handled: Bool = SDKApplicationDelegate.shared.application(application, open: url, options: options)
    
            if handled { return handled }
    
            return GIDSignIn.sharedInstance().handle(url,
                                                     sourceApplication:options[UIApplication.OpenURLOptionsKey.sourceApplication] as? String,
                                                     annotation: [:])
    }
    
    //deprecated method iOS 8 and older
    func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
        let handled: Bool =  SDKApplicationDelegate.shared.application(application,
                                                                       open: url,
                                                                       sourceApplication: sourceApplication,
                                                                       annotation: annotation)
    
        if handled { return handled }
    
        return GIDSignIn.sharedInstance().handle(url,
                                                 sourceApplication: sourceApplication,
                                                 annotation: annotation)
    }
    

提交回复
热议问题