title: Sending Invitation to Facebook Friends with Facebook SDK from IOS App
body: <p>Here I am trying to invite Facebook friends from my app.</p>
  
  <p><a href="https://stackoverflow.com/questions/15495462/presentrequestsdialogmodallywithsession-does-not-work-but-gives-good-result/16654666?"> I followed this answer</a></p>
  
  <p>It works fine with <code>webDialog</code> .But when I click on send button it gives
   exception </p>
  
  <blockquote>
    <p>WebKit discarded an uncaught exception in the 
    webView:decidePolicyForNavigationAction:request:frame:decisionListener:
    delegate:  +[NSInvocation
    _invocationWithMethodSignature:frame:]: method signature argument cannot be nil</p>
  </blockquote>
  
  <p>I am unable to understand whats wrong with my code. Here is my code which i am using</p>
  
  <pre><code>-(void)inviteFriends
      {
          if ([[FBSession activeSession] isOpen])
          {
              NSMutableDictionary* params =  [NSMutableDictionary dictionaryWithObjectsAndKeys:nil];
              [FBWebDialogs presentRequestsDialogModallyWithSession:nil
                                                            message:@"Sending from facebook chat"
                                                              title:nil
                                                         parameters:params
                                                            handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error)
               {
                   if (error)
                   {
                       [self requestFailedWithError:error];
                   }
                   else
                   {
                       if (result == FBWebDialogResultDialogNotCompleted)
                       {
                           [self requestFailedWithError:nil];
                       }
                       else if([[resultURL description] hasPrefix:@"fbconnect://success?request="])
                       {
                           // Facebook returns FBWebDialogResultDialogCompleted even user
                           // presses "Cancel" button, so we differentiate it on the basis of
                           // url value, since it returns "Request" when we ACTUALLY
                           // completes Dialog
                           [self requestSucceeded];
                       }
                       else
                       {
                           // User Cancelled the dialog
                           [self requestFailedWithError:nil];
                       }
                   }
               }
               ];
  
          }
          else
          {
              /*
               * open a new session with publish permission
               */
              [FBSession openActiveSessionWithPublishPermissions:[NSArray arrayWithObject:@"publish_stream"]
                                                 defaultAudience:FBSessionDefaultAudienceFriends
                                                    allowLoginUI:YES
                                               completionHandler:^(FBSession *session, FBSessionState status, NSError *error)
               {
                   if (!error &amp;&amp; status == FBSessionStateOpen)
                   {
                       NSMutableDictionary* params =   [NSMutableDictionary dictionaryWithObjectsAndKeys:nil];
                       [FBWebDialogs presentRequestsDialogModallyWithSession:nil
                                                                     message:@"Sending from facebook chat"
                                                                       title:nil
                                                                  parameters:params
                                                                     handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error)
                        {
                            if (error)
                            {
                                [self requestFailedWithError:error];
                            }
                            else
                            {
                                if (result == FBWebDialogResultDialogNotCompleted)
                                {
                                    [self requestFailedWithError:nil];
                                }
                                else if([[resultURL description] hasPrefix:@"fbconnect://success?request="])
                                {
                                    // Facebook returns FBWebDialogResultDialogCompleted even user
                                    // presses "Cancel" button, so we differentiate it on the basis of
                                    // url value, since it returns "Request" when we ACTUALLY
                                    // completes Dialog
                                    [self requestSucceeded];
                                }
                                else
                                {
                                    // User Cancelled the dialog
                                    [self requestFailedWithError:nil];
                                }
  
                            }
                        }];
                   }
                   else
                   {
                       [self requestFailedWithError:error];
                   }
               }];
          }
  
      }
  
  
   // These methods for requestSucceeded and requestFailed 
  
      - (void)requestSucceeded
      {
          NSLog(@"requestSucceeded1");
          id owner = [_fbDelegate class];
          SEL selector = NSSelectorFromString(@"OnFBSuccess");
          NSMethodSignature *sig = [owner instanceMethodSignatureForSelector:selector];
           _callback = [NSInvocation invocationWithMethodSignature:sig];
          [_callback setTarget:owner];
          [_callback setSelector:selector];
  
          [_callback invokeWithTarget:_fbDelegate];
      }
  
      - (void)requestFailedWithError:(NSError *)error
      {
          NSLog(@"requestFailed");
          id owner = [_fbDelegate class];
          SEL selector = NSSelectorFromString(@"OnFBFailed:");
          NSMethodSignature *sig = [owner instanceMethodSignatureForSelector:selector];
         _callback = [NSInvocation invocationWithMethodSignature:sig];
          [_callback setTarget:owner];
          [_callback setSelector:selector];
          [_callback setArgument:&amp;error atIndex:2];
          [_callback invokeWithTarget:_fbDelegate];
      }
  
      -(void)OnFBSuccess
      {
          NSLog(@"successful");
  
      }
  
      -(void)OnFBFailed:(NSError *)error
      {
          if(error == nil)
              NSLog(@"user cancelled");
          else
              NSLog(@"failed");
      }
  </code></pre>
  
  <blockquote>
    <p>I am also declaring <code>@protocol FBLoginDelegate &lt;NSObject&gt;</code> in
    <code>viewController.h</code>. I don't know whats wrong with the code. Can anyone
    please help me come out of this issue?
    <a href="https://i.stack.imgur.com/z7DUT.png" rel="nofollow noreferrer"> Here is the webDialog appearing with friend list but when i click on
    send.It doesn't send any message.</a></p>
  </blockquote>