简体   繁体   English

如何在Objective C中使用FBWebDialogs发送请求

[英]How to send request using FBWebDialogs in Objective c

I am creating one game in which user can send request to his friends using FBdialogs. 我正在创建一个游戏,用户可以使用FBdialogs向其好友发送请求。 I am using the following code for that. 我正在使用以下代码。

    NSError *error;
    NSData *jsonData = [NSJSONSerialization
                        dataWithJSONObject:@{
                        @"social_karma": @"5",
                        @"badge_of_awesomeness": @"1"}
                        options:0
                        error:&error];
    if (!jsonData) {
        NSLog(@"JSON error: %@", error);
        return;
    }

    NSString *giftStr = [[NSString alloc]
                         initWithData:jsonData
                         encoding:NSUTF8StringEncoding];

    NSMutableDictionary* params = [@{@"data" : giftStr} mutableCopy];


    // Display the requests dialog
    [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 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);
                 }
             }
         }
     }];

This code is sending request successfully to selected user and shows request ID also. 此代码正在成功将请求发送到所选用户,并显示请求ID。 But when I check in friends update. 但是当我签入朋友更新时。 It is not showing any request in his update. 他的更新中没有显示任何请求。

can any one tell me what is wrong in this code? 谁能告诉我这段代码有什么问题? Or should any other method to send request to friends? 还是应该采用其他方法将请求发送给朋友?

Pls check - 请检查-

  1. App Settings 应用程式设定

    You may have forgotten to put the settings for your iOS app into the settings for your app in your App Dashboard 您可能忘记了将iOS应用程序的设置放入“应用程序信息中心”中的应用程序设置

  2. Sandbox Mode 沙盒模式

    Ensure that the sandbox mode is OFF in the App Settings. 确保在“应用程序设置”中sandbox模式为“关闭”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM