[英]Fb request dialog returns nil incorrectly - IOS Facebook
謝謝閱讀!
我正在嘗試創建一個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
為零並且不包含任何內容。 之后我收到“用戶取消請求”的日志消息。
為什么我什么都沒回來? 我需要這個的主要原因是我需要知道請求被發送到哪些朋友。
感謝您的任何幫助!
好像你正在將一個空的空會話傳遞給presentRequestsDialogModallyWithSession
請改用FBSession.activeSession
並檢查您是否有足夠的權限來運行請求(盡管如果沒有,您將收到另一個不同的錯誤)
我認為你沒有打開會話..請嘗試使用它來打開會話。
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.