发送Facebook好友请求邀请返回消息:用户取消请求

时间:2015-02-06 08:33:18

标签: ios facebook facebook-graph-api cocos2d-x

我正在使用此代码,发送邀请好友的朋友请求,此代码给出的消息是用户取消请求。

[FBRequestConnection startWithGraphPath:@"/me/friends"
                             parameters:nil
                             HTTPMethod:@"GET"
                      completionHandler:^(
                                          FBRequestConnection *connection,
                                          id result,
                                          NSError *error
                                          ) {


                          // NSLog(@"%@", result);
                           NSMutableDictionary* params =   [NSMutableDictionary dictionaryWithObjectsAndKeys: [NSString stringWithFormat:@"%@", result], @"to", @"send", @"action_type", @"YOUR_OBJECT_ID", @"object_id", nil];
                          //for (NSDictionary *params in [result objectForKey:@"data"])
                          {
                              [FBWebDialogs
                               presentRequestsDialogModallyWithSession:nil
                               message:@"Learn how to make your iOS apps social."
                               title:nil
                               parameters:params
                               handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error) {
                                   if (error) {
                                       // Error launching the dialog or sending 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 = [appDelegate 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);
                                           }
                                       }
                                   }
                               }];
                         }

                      }];

1 个答案:

答案 0 :(得分:0)

请仅通过添加以下代码并删除此代码上方的块进行检查。

[FBWebDialogs
  presentRequestsDialogModallyWithSession: nil
  message:@"Your invite message"
  title:nil
  parameters:nil
  handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error) {
                                          if (error) {
                                              // An error occurred, we need to handle the error
                                              // See: https://developers.facebook.com/docs/ios/errors
                                              NSLog(@"Error publishing story: %@", error.description);
                                          } else {
                                              if (result == FBWebDialogResultDialogNotCompleted) {
                                                  // User canceled.
                                                  NSLog(@"User cancelled.");
                                              } else {
                                                  // Handle the publish feed callback




                                                  } 

                                        }


}];