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?
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);
}
}];
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.