How to get user info from Facebook SDK in iOS?

Hi you can get the details of Facebook user like:

- (void)sessionStateChanged:(NSNotification*)notification {
    if ([[FBSession activeSession] isOpen]) {
        [FBRequestConnection
         startForMeWithCompletionHandler:^(FBRequestConnection *connection,
                                           id<FBGraphUser> user,
                                           NSError *error) {
             if (! error) {

                //details of user
                NSLog(@"User details =%@",user);
             }
         }];
    }else {
        [[FBSession activeSession] closeAndClearTokenInformation];
    }
}

Thanks


After login authentication, you can get details from active FBSession like below

if (FBSession.activeSession.isOpen) {

    [[FBRequest requestForMe] startWithCompletionHandler:
     ^(FBRequestConnection *connection,
       NSDictionary<FBGraphUser> *user,
       NSError *error) {
         if (!error) {
             NSString *firstName = user.first_name;
             NSString *lastName = user.last_name;
             NSString *facebookId = user.id;
             NSString *email = [user objectForKey:@"email"];
             NSString *imageUrl = [[NSString alloc] initWithFormat: @"http://graph.facebook.com/%@/picture?type=large", facebookId];
         }
     }];
}

Update: Instead of id use objectID property, after release of version v3.14.1(May 12, 2014), the id property has been deprecated

NSString *facebookId = user.objectID;