[英]Fb request dialog returns nil incorrectly - IOS Facebook
Thanks for reading! 谢谢阅读!
I'm trying to create a Facebook request to enable the user to invite his friends to the app. 我正在尝试创建一个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);
}
}
}
}];
} }
This is pretty much a clean copy of the Facebook docs code. 这几乎是Facebook文档代码的干净副本。 And it works up to a point The user can choose the friends and the request goes away and gets received by the friends and it shows up as a notification - everything fine so far.
并且它可以达到一定程度用户可以选择朋友并且请求消失并被朋友接收并且它显示为通知 - 到目前为止一切都很好。
The problem is that when I try to get the response from the "handler" the resultURL
is nil and does not contain anything. 问题是,当我尝试从“处理程序”获取响应时,
resultURL
为零并且不包含任何内容。 And after that I get the log message "User canceled request". 之后我收到“用户取消请求”的日志消息。
Why don't I get anything back? 为什么我什么都没回来? The main reason that I need this is that I need to know which friends the request was sent to.
我需要这个的主要原因是我需要知道请求被发送到哪些朋友。
Thank you for any help! 感谢您的任何帮助!
Seems like you're passing an nil empty session to presentRequestsDialogModallyWithSession
好像你正在将一个空的空会话传递给
presentRequestsDialogModallyWithSession
Use FBSession.activeSession
instead and check you have enough permissions to run the request (although if not, you would be getting another different error) 请改用
FBSession.activeSession
并检查您是否有足够的权限来运行请求(尽管如果没有,您将收到另一个不同的错误)
I think you are not having a session opened..please try to use this to open the session. 我认为你没有打开会话..请尝试使用它来打开会话。
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) {
}];
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.