我正在寻求实现Google和Facebook登录功能。它们都具有应该在appDelegate中使用的url处理方法。现在我如何在这里区分这两个请求。

Facebook方法就是这样。

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

          // Call FBAppCall's handleOpenURL:sourceApplication to handle Facebook app responses
             BOOL wasHandled = [FBAppCall handleOpenURL:url sourceApplication:sourceApplication];

          // You can add your app-specific url handling code here if needed

              return wasHandled;
   }

Google的方法如下所示:
 - (BOOL)application: (UIApplication *)application
        openURL: (NSURL *)url
   sourceApplication: (NSString *)sourceApplication
     annotation: (id)annotation {
         return [GPPURLHandler handleURL:url
               sourceApplication:sourceApplication
                  annotation:annotation];
 }

最佳答案

只是

 return [GPPURLHandler handleURL:url
               sourceApplication:sourceApplication
                  annotation:annotation] || [FBAppCall handleOpenURL:url sourceApplication:sourceApplication];

10-04 19:17