繁体   English   中英

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

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

我正在创建一个游戏,用户可以使用FBdialogs向其好友发送请求。 我正在使用以下代码。

    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);
                 }
             }
         }
     }];

此代码正在成功将请求发送到所选用户,并显示请求ID。 但是当我签入朋友更新时。 他的更新中没有显示任何请求。

谁能告诉我这段代码有什么问题? 还是应该采用其他方法将请求发送给朋友?

请检查-

  1. 应用程式设定

    您可能忘记了将iOS应用程序的设置放入“应用程序信息中心”中的应用程序设置

  2. 沙盒模式

    确保在“应用程序设置”中sandbox模式为“关闭”。

暂无
暂无

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

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