3

I didn't have this problem with fb SDK 3.2, but after I upgraded it in SDK 3.5.1 friend inviter has some strange problem, when I select one friend it choose the selected one and the one under it. Also when I am trying to scroll downward it restarts the table and brings me back on the tables top. Here is my method:

-(IBAction)secondClick:(id)sender
{
NSDictionary *params = [[NSDictionary alloc] initWithObjectsAndKeys:nil];

[FBWebDialogs
 presentRequestsDialogModallyWithSession:nil
 message:@"Learn how to make your iOS apps social."
 title:@"Test"
 parameters:params
 handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error) {
     if (error) {
         // Error launching the dialog or sending the request.
         NSLog(@"Error sending request.");
     } else {
         if (result == FBWebDialogResultDialogNotCompleted) {
             // User clicked the "x" icon
             NSLog(@"User canceled request.");
         } else {
             // Handle the send request callback
             NSDictionary *urlParams = [self parseURLParams:[resultURL query]];
             if (![urlParams valueForKey:@"request"]) {
                 // User clicked the Cancel button
                 NSLog(@"User canceled request.");
             } else {
                 // User clicked the Send button
                 NSString *requestID = [urlParams valueForKey:@"request"];
                 NSLog(@"Request ID: %@", requestID);
             }
         }
     }
 }];
Wain
  • 118,658
  • 15
  • 128
  • 151
de Jan
  • 55
  • 1
  • 8

2 Answers2

1

From what i have come to know is that facebook has fixed this issue and is going to make the fix live soon. An alternate solution to this is to make your own custom UI. 1. Get Friends List - [self startConnectionWithGraphPath:@"me/friends" parameters:params method:@"GET" completionSelector:@selector(callback)]

  1. Download pictures using url @"https://graph.facebook.com/fbid/picture"

  2. Implement a table view similar to facebook's request ui showing list of friends along with their profile pics.

  3. Use 'to' param to direct the request to the selected user(s). NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys: @"286400088", @"to", nil];

This way you won't need to show facebook ui to select friends. Al though the UI will still appear after user selects friends from your custom UI, but that'd be just to tap 'send'.

Nitin Garg
  • 2,069
  • 6
  • 25
  • 50
0

One way is to use the Facebook friendPicker

https://developers.facebook.com/ios/friendpicker-ui-control/

And then take the facebook id's result of that and put them into the requestdialog just like Nitin said.

I'll post my friendPicker code:

- (IBAction)inviteFriendsClicked:(id)sender {

    // Initialize the friend picker


    FBFriendPickerViewController *friendPickerController =
    [[FBFriendPickerViewController alloc] init];
    // Set the friend picker title
    friendPickerController.title = @"Välj vänner";

    // TODO: Set up the delegate to handle picker callbacks, ex: Done/Cancel button

    // Load the friend data
    [friendPickerController loadData];
    // Show the picker modally
    [friendPickerController presentModallyFromViewController:self
                                                    animated:YES
                                                     handler:
     ^(FBViewController *sender, BOOL donePressed) {
         if(donePressed) {
             NSString *userString;
             userString = @"";
             int *counter = 0;
             for (id<FBGraphUser> user in friendPickerController.selection) {
                 NSLog(user.id);
                 NSMutableArray *userArray = [[NSMutableArray alloc] init];
                 [userArray addObject:user.id];

                 if(counter == 0){
                     userString = user.id;
                 }else{
                     userString = [NSString stringWithFormat:@"%@%@%@", userString, @",", user.id];
                 }

                 counter++;

             }

             if(counter != 0){
                 [self requestDialog: userString]; // Display the requests dialog and send the id-string with it
             }
             // NSLog(@"Selected friends: %@", friendPickerController.selection);
         }
     }];



}
PaperThick
  • 2,749
  • 4
  • 24
  • 42