如何在ios中集成FB和Google plus?

时间:2014-06-19 10:36:36

标签: google-plus ios7.1

我想整合fb loging和google plus登录到我的ios应用程序。我已经整合了fbloging。现在我想整合Google plus loging.Now在appdelegate中我已经完成了这个委托。

`

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


return [FBAppCall handleOpenURL:url
              sourceApplication:sourceApplication];

}`

现在我想将这些代码添加到Google plus的相同代表中。

`

 return [GPPURLHandler handleURL:url
           sourceApplication:sourceApplication
                  annotation:annotation];`

如何在不影响FB登录的情况下将此代码添加到同一代理中。

请帮帮我 感谢

3 个答案:

答案 0 :(得分:1)

我想你可以将调用链接起来:

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

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

我不确定这是否会起作用,但它会编译。

答案 1 :(得分:0)

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

    BOOL returnURL;
    NSString *urlSTR=[NSString stringWithFormat:@"%@",url];
    NSArray *tempArr=[urlSTR componentsSeparatedByString:@"/"];
    NSString *tempStr=[tempArr objectAtIndex:0];
    if ([tempStr isEqualToString:@"fbYOUR_APP_ID:"]) {
        BOOL urlWasHandled = [FBAppCall handleOpenURL:url
                                    sourceApplication:sourceApplication
                                      fallbackHandler:^(FBAppCall *call) {
                                          NSLog(@"Unhandled deep link: %@", url);
                                          // Parse the incoming URL to look for a target_url parameter
                                          NSString *query = [url fragment];
                                          if (!query) {
                                              query = [url query];
                                          }
                                          NSDictionary *params = [self parseURLParams:query];
                                          // Check if target URL exists
                                          NSString *targetURLString = [params valueForKey:@"target_url"];
                                          if (targetURLString) {
                                              // Show the incoming link in an alert
                                              // Your code to direct the user to the appropriate flow within your app goes here
                                              [[[UIAlertView alloc] initWithTitle:@"Received link:"
                                                                          message:targetURLString
                                                                         delegate:self
                                                                cancelButtonTitle:@"OK"
                                                                otherButtonTitles:nil] show];
                                          }
                                      }];

        returnURL=urlWasHandled;

    }
else if ([tempStr isEqualToString:@"igINSTAGRAM_APP_ID:"]){
        returnURL=[self.instagram handleOpenURL:url];
    }
else{
        returnURL= [GPPURLHandler handleURL:url
                      sourceApplication:sourceApplication
                             annotation:annotation];
    }

    return returnURL;
}

答案 2 :(得分:0)

- (BOOL) application:(UIApplication *) application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation{
BOOL wasHandled=false;
if ([url.scheme hasPrefix:@"fb"])
 {
wasHandled = [FBAppCall handleOpenURL:url sourceApplication:sourceApplication];
//Facebook callback
}
else//Google Plus callback
{
wasHandled=  [GPPURLHandler handleURL:url sourceApplication:sourceApplication annotation:annotation];
}
return wasHandled;
}