Not getting loginViewShowingLoggedInUser call from FBLoginView

This is my first time using the SDK for Facebook. I work with Xcode 5.1 and iOS 7.

I programmatically show FBLoginView:

- (void)viewDidLoad { [super viewDidLoad]; NSLog(@"viewDidLoad"); // Do any additional setup after loading the view. if ( !loginView ) { // loginView =[[FBLoginView alloc] initWithReadPermissions:@[@"basic_info"]]; loginView =[[FBLoginView alloc] initWithReadPermissions:[NSArray arrayWithObjects:@"basic_info", @"user_location", nil]]; } loginView.delegate = self; loginView.frame = CGRectOffset(loginView.frame, (self.view.center.x -(loginView.frame.size.width /2)), 5); CGPoint vCenter = CGPointMake( CGRectGetMidX(self.view.frame), CGRectGetMidY(self.view.frame) ); CGPoint lvCenter = CGPointMake( vCenter.x, vCenter.y+100.0 ); loginView.center = lvCenter; [self.view addSubview:loginView]; [self updateView]; } 

I performed the necessary override functions:

 #pragma mark - FBLoginViewDelegate - (void) loginViewFetchedUserInfo:(FBLoginView *)loginView user:(id<FBGraphUser>)user { NSLog(@"loginViewFetchedUserInfo"); [self updateView]; } - (void) loginViewShowingLoggedInUser:(FBLoginView *)loginView { NSLog(@"loginViewShowingLoggedInUser"); [self updateView]; } - (void) loginViewShowingLoggedOutUser:(FBLoginView *)loginView { NSLog(@"loginViewShowingLoggedOutUser"); [self updateView]; } - (void)updateView { NSLog(@"FB updateView"); [[FBRequest requestForMe] startWithCompletionHandler: ^(FBRequestConnection *connection, NSDictionary<FBGraphUser>*FBUser, NSError *error) { if (error) { NSLog(@"updateView - error"); } else { NSLog(@"updateView - good"); NSNumber *owner_id = [NSNumber numberWithLong:[[FBUser id] longLongValue]]; if ( FB_user_id == nil ) { FB_user_id = owner_id; NSLog(@"FBUser ID = %@", FB_user_id); loggedInSession = [FBSession activeSession]; [[NSUserDefaults standardUserDefaults] setObject:[FBUser id] forKey:@"eventOwnerID"]; [self performSegueWithIdentifier:@"continue_to_app" sender:self]; } } }]; if ([self checkFacebookSession]) { } dispatch_async(dispatch_get_main_queue(), ^{ [self.view setNeedsDisplay]; }); } 

The FBLoginView button with "Sign in to Facebook" will appear. I can register and accept permissions, but the loginViewShowingLoggedInUser override function is never called.

Someone suggested adding the following:

 - (BOOL) application:(UIApplication *) application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation { NSLog ( @"application openURL"); NSLog ( @"URL = %@", url); NSLog ( @"Application = %@", sourceApplication); // Call FBAppCall ha BOOL wasHandled = [FBAppCall handleOpenURL:url sourceApplication:sourceApplication]; //[LoginUIViewController updateView]; return wasHandled; } 

This code had no effect and was never executed.

What am I doing wrong?

+6
source share
2 answers
  • You use @ "basic_info" because this Facebook shows the following error when I tried to check your code!

     Invalid Scope: basic_info. Use public_profile, user_friends instead 
  • I was interested to know where you added the method:

     - (BOOL) application:(UIApplication *) application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation { NSLog ( @"application openURL"); NSLog ( @"URL = %@", url); NSLog ( @"Application = %@", sourceApplication); // Call FBAppCall ha BOOL wasHandled = [FBAppCall handleOpenURL:url sourceApplication:sourceApplication]; //[LoginUIViewController updateView]; return wasHandled; } 

It should be in your AppDelegate, which works for me.

+3
source

Read permissions have changed. Please note: [ https://developers.facebook.com/docs/apps/changelog#v2_0_permissions ] [1]

The error "invalid area: basic information uses public_profile, user friends instead," clearly states that "basic_info" is invalid and suggests using "public_profile" or "user_friends" as a new area.

Change it in the following code:

  self.loginView.readPermissions = @[@"basic_info"]; 

TO

  self.loginView.readPermissions = @[@"public_profile"]; 
+2
source

All Articles