简体   繁体   中英

Login with facebook with native app

I need to facebook login via custom button.
So I made following method.

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

After that I check in real device (iPhone 5s(iOS 9.0)) but It is opening browser for login.
I have installed and logged in facebook app in my device.
though I am facing this problem.
Please help me.

I noticed following changelogs:

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM