在iOS中集成Google和Facebooklogin – AppDelegate openURL

我试图将Facebook和谷歌login整合到我的应用程序,但有一个问题:两个都需要添加到Appdelegate的openURL方法:

return [GIDSignIn sharedInstance] handleURL:url sourceApplication:sourceApplication annotation:annotation]]; return [FBSDKApplicationDelegate sharedInstance] application:application openURL:url sourceApplication:sourceApplication annotation:annotation ]] 

有没有办法让这两个工作正常。 我在网上查找,但答案很模糊,并没有提供一个很好的解释

添加了以下为我做的伎俩(截至iOS 9):

 return [[GIDSignIn sharedInstance] handleURL:url sourceApplication:sourceApplication annotation:annotation] || [[FBSDKApplicationDelegate sharedInstance] application:application openURL:url sourceApplication:sourceApplication annotation:annotation ]; 

使用下面的代码…

 - (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]]; } 

另一个答案..

 - (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]; } }