Integrating Google and Facebook login in 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 ];

use following code...

- (BOOL)application:(UIApplication *)applicationopenURL:(NSURL *)url
      sourceApplication:(NSString *)sourceApplicationannotation:(id)annotation
    {
      if ([FBAppCall handleOpenURL:url sourceApplication:sourceApplication])
        return [FBSDKApplicationDelegate sharedInstance] application:application
                                                       openURL:url
                                             sourceApplication:sourceApplication
                                                    annotation:annotation
         ]];
      else

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

another answer..

- (BOOL)application:(UIApplication *)applicationopenURL:(NSURL *)url
  sourceApplication:(NSString *)sourceApplicationannotation:(id)annotation
{

     NSString *stringURL = [ url absoluteString];
    if([stringURL containsString:@"fb"])
    {


    return [[FBSDKApplicationDelegate sharedInstance] application:application
                                                          openURL:url
                                                sourceApplication:sourceApplication
                                                       annotation:annotation];
    }
    else
    {
        return [GPPURLHandler handleURL:url
                      sourceApplication:sourceApplication
                             annotation:annotation];

    }
}
链接地址: http://www.djcxy.com/p/88208.html

上一篇: 用ajax选择2个默认选项

下一篇: 在iOS中集成Google和Facebook登录