ios - 使用 native 应用程序登录 Facebook

标签 ios objective-c facebook facebook-login

我需要通过自定义按钮登录 Facebook。
所以我做了以下方法。

- (IBAction)loginWithFBClick:(UIButton *)sender
{
    FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];
    login.loginBehavior = FBSDKLoginBehaviorNative;

    [login
     logInWithReadPermissions: @[@"public_profile"]
     fromViewController:self
     handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {
         if (error) {
             NSLog(@"Process error:%@",error);
         } else if (result.isCancelled) {
             NSLog(@"Cancelled");
         } else {
             NSLog(@"Logged in");
             HomeViewController *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"HomeVC"];
             [self.navigationController pushViewController:vc animated:YES];
         }
     }];
}

之后我检查了真实设备(iPhone 5s(iOS 9.0))但它正在打开浏览器进行登录。
我已在我的设备中安装并登录了 facebook 应用程序。
虽然我面临这个问题。
请帮助我。

最佳答案

我注意到以下变更日志:

Facebook SDK for iOS Changelog v4.x

(v4.6.0 - September 10, 2015) In addition, the SDK dialogs such as Login, Like, Share Dialogs automatically determine the best UI based on the device, including SFSafariViewController instead of Safari. Follow the our Preparing for iOS 9 guide.

关于ios - 使用 native 应用程序登录 Facebook,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33910270/

相关文章:

ios - 用户切换选项卡栏项目后导航项目未更新

ios - 如何在 xcode 中使 5 个按钮的水平宽度相同

android - 在多列中显示重复项

ios - 如何使用 nib 文件为 TableView 创建动态单元格

objective-c - 设置背景图像尺寸 IOS

iphone - 检查 Controller 是否在导航 Controller 堆栈的顶部

iOS、REST API - Facebook 登录

python - Django 中 ForeignKeys、ManyToMany 和 GenericForeignKeys 的最佳实践

ios - 如何将数组中的元素与indexPath.item进行比较?

javascript - 加载图像时显示消息