0

I am using parse framework to manage users. I have an option in my app where the users can login from facebook.

I have linked the FacebookAppID and URL scheme in plist file.

According to parse documentation the recommended code here is below

[PFFacebookUtils logInWithPermissions:@[ @"email",@"user_about_me", @"user_relationships", @"user_birthday", @"user_location"] block:^(PFUser *user, NSError *error) 
{
   if (user)
   {
        NSLog(@"User authenticated from facebook.");
        FBRequest *request = [FBRequest requestForMe];
       [request startWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
       if (!error)
       {
           NSLog(@"Facebook id fetched.");
           // result is a dictionary with the user's Facebook data
           NSDictionary *userData = (NSDictionary *)result;

       }
   }
   else
   {
       // User not authenticated
   }
]];

Now as you can see i have entered proper permissions for email,user_about_me,user_relationships,user_birthday, user_location

But the result dictionary i am getting from facebook only return name and id everytime and for every user.

I also want rest of the information. Any one know why i am not getting all user data?

Its not duplicate

Awesome.Apple
  • 1,316
  • 1
  • 11
  • 24

1 Answers1

0

Use this code-

-(void)fectchUserInfo {

FBRequest *req = [[FBRequest alloc] initWithSession:[FBSession activeSession] graphPath:@"me?

fields=first_name,last_name,gender,id,email"];

[req startWithCompletionHandler:^(FBRequestConnection *connection, id result,NSError *error) {
    if(error) {
        NSLog(@"fb error");
        [self handleAuthError:error];
        return;
    }
    else{
        facebookFirstName = [result objectForKey:@"first_name"];

        facebookLastName  = [result objectForKey:@"last_name"];

        facebookID  = [result objectForKey:@"id"];

        facebookEmail  = [result objectForKey:@"email"];

        NSLog(@"fb data:%@ %@ %@ %@ ",facebookFirstName,facebookLastName,facebookID,facebookEmail);

        facebookPassword = [NSString stringWithFormat:@"%@_%@",facebookID,@"fb"];


        NSLog(@"fb password is :%@",facebookPassword);

    }

}];

}

Avinash651
  • 1,399
  • 11
  • 17