Pergunta

I'm trying to figure out how to get a random userID from my friends.

is there a way to do it with "friendPickerController" ? the only "count" method I've found is in the selection, which dosen't help.

Foi útil?

Solução

You can get the total friend count using following method

FBRequest* friendsRequest = [FBRequest requestForMyFriends];
[friendsRequest startWithCompletionHandler: ^(FBRequestConnection *connection,
                                  NSDictionary* result,
                                  NSError *error) {
    NSArray* friends = [result objectForKey:@"data"];


    NSLOG(@"Total Friend :%@",friends.count);
}];

Outras dicas

Just updating in case this helps anyone. While Dipak's answer worked flawlessly for me at the end, it didn't work until I added permission to retrieve the count. I added the following lines of code just before Dipak's code and it returned me the proper friend count.

NSArray *permissions = [NSArray arrayWithObjects:@"friends_about_me", nil];
[FBSession openActiveSessionWithReadPermissions:permissions
                                       allowLoginUI:YES
                                  completionHandler:^(FBSession *session, FBSessionState status, NSError *error) {


                                  }];

[FBSession setActiveSession:[FBSession activeSession]];
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top