使用Facebook-iOS-SDK(4.0.1)result.isCancelled在使用浏览器时设置 [英] Using Facebook-iOS-SDK (4.0.1) result.isCancelled is set when using a browser

查看:427
本文介绍了使用Facebook-iOS-SDK(4.0.1)result.isCancelled在使用浏览器时设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Facebook-iOS-SDK(4.0.1)登录自定义按钮。我正在执行以下代码

I'm using Facebook-iOS-SDK (4.0.1) for logging in with custom button. I'm implementing the following code

- (IBAction)fbButtonClicked:(UIButton *)sender {
FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];
[login logInWithReadPermissions:@[@"email"] handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {
    if (error) {
        // Process error
    } else if (result.isCancelled) {
        // Handle cancellations
    } else {
        // If you ask for multiple permissions at once, you
        // should check if specific permissions missing
        if ([result.grantedPermissions containsObject:@"email"]) {
            // Do work
            if ([FBSDKAccessToken currentAccessToken]) {


                [[[FBSDKGraphRequest alloc] initWithGraphPath:@"me/friends" parameters:nil]
                 startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result2, NSError *error) {

                     if (!error) {
                         NSLog(@"fetched user:%@", result2);
                     }
                 }];
            }
        }
    }
}];

}

安装在设备上,代码工作正常。当我没有安装Facebook应用程序时,Facebook会在浏览器中打开。在这里,'result.isCancelled'设置为'YES',我没有得到所需的结果。

if I have facebook app installed on a device then the code works fine. When I do not have facebook app installed, then the facebook is opened in a browser. Here, 'result.isCancelled' is set to 'YES' and I do not get a required result.

推荐答案

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
  return [[FBSDKApplicationDelegate sharedInstance] application:application
                                                        openURL:url
                                              sourceApplication:sourceApplication
                                                     annotation:annotation];
}

需要在appDelegate.m

is required in appDelegate.m

这篇关于使用Facebook-iOS-SDK(4.0.1)result.isCancelled在使用浏览器时设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆