Reputation: 105
I am trying to use FBFriendPickerViewController
to get a list of facebook friends to send app invitations. The friend list is empty whenever I test the code. Please see the code below:
@implementation FacebookInviteViewController
- (void)showFriendPicker
{
FBFriendPickerViewController *friendPicker = [[FBFriendPickerViewController alloc] init];
friendPicker.title = @"Invite Friends";
friendPicker.delegate = self;
[friendPicker loadData];
AppController *appController = (AppController *)[[UIApplication sharedApplication] delegate];
[appController.navController presentViewController:friendPicker animated:YES completion:nil];
}
-(void)inviteFromFacebookSelected
{
if (!FBSession.activeSession.isOpen) {
[FBSession openActiveSessionWithReadPermissions:nil
allowLoginUI:YES
completionHandler:^(FBSession *session,
FBSessionState state,
NSError *error) {
if (error) {
UIAlertView *alertView =
[[UIAlertView alloc] initWithTitle:@"Error"
message:error.localizedDescription
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alertView show];
} else if (session.isOpen) {
[self showFriendPicker];
}
}];
} else {
[self showFriendPicker];
}
}
In the Settings class (subclassed from CCLayer) I call the following method when the facebook button is pressed
-(void)showFbConnect {
facebookInviteViewController = [[FacebookInviteViewController alloc] init];
[facebookInviteViewController inviteFromFacebookSelected];
}
How can I solve this issue?
Upvotes: 1
Views: 485
Reputation: 1271
Small addition to @Bhumit's answer. You can go to your app page on Facebook and in the roles section add test users. Facebook creates test users for you at the click of a button. You can then manage these users and their friends. This should help in testing.
Upvotes: 2
Reputation: 16318
Graph API version 2.0 and above will only return App using friends.That means you will only get list of those friends who have authorized your app. So if you have created a new app at facebook and if none of your friends from your friendlist have authorized your app than FBFriendPickerViewController
will be empty.
Check the change log at official facebook docs
App Friends: The /me/friends endpoint no longer includes the full list of a person's friends. Instead, it now returns the list of that person's friends who are also using your app.
If you want to test you can authorize your app from one of your friends account and than that friend will be shown in FBFriendPickerViewController
Upvotes: 4