0
FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];
[FBSDKProfile enableUpdatesOnAccessTokenChange:YES];
login.loginBehavior = FBSDKLoginBehaviorSystemAccount;
[login logInWithReadPermissions:@ [@"email"]  handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {
    if (error)
    {
         [MBProgressHUD hideHUDForView:self.view animated:YES];
    }
    else if (result.isCancelled)
    {
         [MBProgressHUD hideHUDForView:self.view animated:YES];
    }
    else
    {
        [MBProgressHUD hideHUDForView:self.view animated:YES];
        if ([result.grantedPermissions containsObject:@"email"])
        {
            if ([FBSDKAccessToken currentAccessToken])
            {
                [[[FBSDKGraphRequest alloc] initWithGraphPath:@"me" parameters:nil]
                 startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
                     if (!error) {
                         NSLog(@"fetched user:%@", result);
                     }
                 }];
            }
        }
    }
}];

I want to get email address for FB user, But from above code I'm just getting id and name only. Can anyone please suggest me how can I get email address?

Amit
  • 535
  • 4
  • 13

1 Answers1

4

you need to pass perameter whatever u want to read Like

[[[FBSDKGraphRequest alloc] initWithGraphPath:@"me" parameters:@{@"fields": @"id, name, link, first_name, last_name, picture.type(large), email, birthday, bio ,location ,friends ,hometown , friendlists"}]
     startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
         if (!error)
         {
             NSLog(@"resultis:%@",result);
         }
         else
         {
             NSLog(@"Error %@",error);
         }
     }];
Kanjariya-IOS
  • 652
  • 1
  • 5
  • 17