【问题标题】:iphone development: how to handle fbwebdialogs pop-up buttonsiphone开发:如何处理fbwebdialogs弹出按钮
【发布时间】:2013-05-29 19:19:00
【问题描述】:

在我的应用程序中,我使用 FBWebDialogs 将应用程序请求发送给 facebook 朋友,我成功地做到了。我的问题是我无法处理 FBWebDialogs 弹出窗口按钮。在下面的代码中,我可以检测到 X 按钮和取消按钮,但是当我选择发送按钮时,它仍然给出日志 NSLog(@"User canceled request."); 我正在使用 facebook 文档中给出的代码。我的错误是什么?

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

我有这样的 parseURLParams 函数:

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

        [params setObject:val forKey:[kv objectAtIndex:0]];
    }
    return params;
}

【问题讨论】:

    标签: iphone ios objective-c facebook dialog


    【解决方案1】:

    我发现这是一个常见的问题,因为 SDK 3.5 中的一个错误,所以我将 sdk 从 3.5 更新到 3.5.1 并且问题解决了。

    【讨论】:

      猜你喜欢
      • 2011-09-14
      • 2012-09-15
      • 2017-09-07
      • 1970-01-01
      • 2012-12-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多