确保您的Facebook应用程序ID在这两个开发者页面和信息在Xcode相同下,使沙盒模式,并必须填写帆布开发者页面中的[在Facebook类别下的应用程序]。
NSString *facebookID = @"Your friend facebook id";
NSMutableDictionary* params =
[NSMutableDictionary dictionaryWithObject:facebookID forKey:@"to"];
NSString *message = @"SOME_MESSAGE";
NSString *title = @"TITLE";
[FBWebDialogs presentRequestsDialogModallyWithSession:nil
message:message
title:title
parameters:params handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error) {
if (error)
{
// Case A: Error launching the dialog or sending request.
NSLog(@"Error sending request.");
}
else
{
if (result == FBWebDialogResultDialogNotCompleted)
{
// Case B: User clicked the "x" icon
NSLog(@"User canceled request.");
}
else
{
NSLog(@"Request Sent. %@", params);
}
}}];
为什么不想用Facebook-sdk 3.1? –