【问题标题】:Fb request dialog returns nil incorrectly - IOS FacebookFb 请求对话框错误地返回 nil - IOS Facebook
【发布时间】:2013-05-28 10:46:06
【问题描述】:

感谢阅读!

我正在尝试创建一个 Facebook 请求,以使用户能够邀请他的朋友加入该应用程序。

 NSDictionary *params = [[NSDictionary alloc] initWithObjectsAndKeys:nil];

        [FBWebDialogs
         presentRequestsDialogModallyWithSession:nil
         message:@"Learn how to make your iOS apps social."
         title:@"Test"
         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);
                     }
                 }
             }
         }];    

}

这几乎是 Facebook 文档代码的干净副本。它在一定程度上起作用 用户可以选择朋友,请求消失并被朋友接收,并显示为通知 - 到目前为止一切都很好。

问题是,当我尝试从“处理程序”获取响应时,resultURL 为 nil 并且不包含任何内容。之后我收到日志消息“用户取消请求”。

为什么我没有得到任何回报?我需要这个的主要原因是我需要知道请求发送给了哪些朋友。

感谢您的帮助!

【问题讨论】:

    标签: iphone ios objective-c facebook facebook-requests


    【解决方案1】:

    似乎您将一个空会话传递给presentRequestsDialogModallyWithSession

    改用FBSession.activeSession 并检查您是否有足够的权限来运行请求(如果没有,您会收到另一个不同的错误)

    【讨论】:

      【解决方案2】:

      我认为您没有打开会话。请尝试使用它打开会话。

      if (!FBSession.activeSession.isOpen) {
              // if the session is closed, then we open it here, and establish a handler for state changes
                  [FBSession openActiveSessionWithReadPermissions:nil
                                                     allowLoginUI:YES
                                                completionHandler:^(FBSession *session,
                                                                       FBSessionState state,
                                                                       NSError *error) {
           }];
          }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2023-03-20
        • 1970-01-01
        • 2012-10-29
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多