Evyatar Apteker
Evyatar Apteker

Reputation: 11

IOS facebook api - Getting freind's username

I'm using Facebook api in my ios application. Using the FBFriendPickerViewController's delegate method: 'shouldIncludeUser' i'm trying to filter the user's friends list according to the username property of the FBGraphUser object.

The problem is that i keep on getting null values for the username property although this property declared in the documentation as a non access_key required.

Thanks, Evyatar

Upvotes: 0

Views: 205

Answers (1)

Evyatar Apteker
Evyatar Apteker

Reputation: 11

Finally found it! Apparently the FBFriendPickerViewController object has a property named: 'fieldsForRequest'. using this property i could set extra properties to retrieve from the server which are not retrieved by default.

In my case i only needed the username property:

FBFriendPickerViewController *friendPickerController = [[FBFriendPickerViewController alloc] init];
    friendPickerController.title = @"Pick Friends";
    friendPickerController.delegate = self;

    friendPickerController.fieldsForRequest = [NSSet setWithObjects:@"username", nil];

    [friendPickerController loadData];      
    // Use the modal wrapper method to display the picker.
    [friendPickerController presentModallyFromViewController:self animated:YES handler:
     ^(FBViewController *sender, BOOL donePressed) {
         if (!donePressed) {
             return;
         }


     }];

Upvotes: 1

Related Questions