5

I am trying to send invitation for App from my iOS native app to Facebook friend using facebook SDK using below method.

-(IBAction)ShowFiendDialog:(id)sender
{

    NSDictionary *parameters = @{@"to":@""};

    [FBWebDialogs presentRequestsDialogModallyWithSession:FBSession.activeSession
                                                  message:@"my message"
                                                    title:@"my title"
                                               parameters:parameters
                                                  handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error)
     {
         if(error)
         {
             NSLog(@"Some errorr: %@", [error description]);
             UIAlertView *alrt = [[UIAlertView alloc] initWithTitle:@"Invitiation Sending Failed" message:@"Unable to send inviation at this Moment, please make sure your are connected with internet" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil];
             [alrt show];
             //[alrt release];
         }
         else
         {
             if (![resultURL query])
             {
                 return;
             }

             NSDictionary *params = [self parseURLParams:[resultURL query]];
             NSMutableArray *recipientIDs = [[NSMutableArray alloc] init];
             for (NSString *paramKey in params)
             {
                 if ([paramKey hasPrefix:@"to["])
                 {
                     [recipientIDs addObject:[params objectForKey:paramKey]];
                 }
             }
             if ([params objectForKey:@"request"])
             {
                 NSLog(@"Request ID: %@", [params objectForKey:@"request"]);
             }
             if ([recipientIDs count] > 0)
             {
                 //[self showMessage:@"Sent request successfully."];
                 //NSLog(@"Recipient ID(s): %@", recipientIDs);
                 UIAlertView *alrt = [[UIAlertView alloc] initWithTitle:@"Success!" message:@"Invitation(s) sent successfuly!" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil];
                 [alrt show];
                 //[alrt release];
             }

         }
     }friendCache:nil];

}

- (NSDictionary *)parseURLParams:(NSString *)query
{
    NSArray *pairs = [query componentsSeparatedByString:@"&"];
    NSMutableDictionary *params = [[NSMutableDictionary alloc] init];
    for (NSString *pair in pairs)
    {
        NSArray *kv = [pair componentsSeparatedByString:@"="];

        [params setObject:[[kv objectAtIndex:1] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]
                   forKey:[[kv objectAtIndex:0] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
    }

    return params;
}

Using this above code I got Prompt all my friends' list and after checking multiple or single friend, that request was sent successfully. But when my friends open facebook in web or facebook native app not any notification or message is received. I can't find where is the mistake in code.

Please help me on this. Where is my mistake and how can I solve this?

MysticMagicϡ
  • 28,593
  • 16
  • 73
  • 124
Nitin Gohel
  • 49,482
  • 17
  • 105
  • 144
  • use this link it will work http://stackoverflow.com/questions/11796445/facebook-app-requests-arent-shown-on-ios-devices –  Oct 08 '15 at 10:49

1 Answers1

5

You have to configure your app on facebook by passing some dummy url, i was also facing the same problem, doing so worked for me. Go to developer.facebook.com, choose your app, choose settings, AddPlatform---> addApplication, pass any dummy url there, also add image for your app which will be shown in notification from the app details scrren.

Rahul Mathur
  • 872
  • 1
  • 7
  • 20
  • It need to be submit before can do this? – Khoi Nguyen Aug 18 '14 at 04:33
  • @GấuUni no you do not need to submit your app to do this. Do remember to make your app live (by default it is in sandbox mode which do not allow app to be tested with other fb accounts except the fb account registered) – Rahul Mathur Aug 18 '14 at 04:36
  • 1
    I have made it public. Everyone can authorize. I send request successfully. But my friends do not receive any notification on web or mobile. Please help me. can you give me something that I can contact you – Khoi Nguyen Aug 18 '14 at 04:39
  • Where i can add url and images i haven't get any option please let me know i m also facing the same problem@nitin – Mohit Dec 27 '14 at 19:03