我过去做过类似的事情。
这是一个流程,任何持有 iPad 的用户都使用他或她的 FB 凭据登录,强制 sdk 呈现 web 视图。
快速浏览一下,这是我为它编写的代码:
(此代码已有 1.5 年的历史)
FBSession *newSession = [[FBSession alloc] initWithPermissions:@[
@"user_about_me",
@"publish_actions",
@"user_birthday",
@"friends_birthday",
@"email"
]];
[FBSession setActiveSession:newSession];
[[FBSession activeSession] openWithBehavior:FBSessionLoginBehaviorForcingWebView completionHandler:^(FBSession *session, FBSessionState status, NSError *error) {
[FBSession setActiveSession:session];
if(error){
NSLog(@"Error opening session");
[self showLoginError:error];
return;
}
if(status == FBSessionStateOpen){
NSLog(@"FB session opened");
[self getMe];
}
}];
当流程结束,或者用户取消流程时,我将用户注销如下:
[[FBSession activeSession] closeAndClearTokenInformation];
[FBSession setActiveSession:nil];
更新:
分享对话框的代码:
NSMutableDictionary *dialogParameters = [NSMutableDictionary dictionaryWithObjectsAndKeys:
[NSString stringWithFormat:@"%@ - Vote for us!",
teamName, @"name",
@"Campaign title", @"caption",
shareMessage, @"description",
shareTeamPageURL, @"link",
sharePictureURL, @"picture", nil];
[FBWebDialogs presentFeedDialogModallyWithSession:[FBSession activeSession]
parameters:dialogParameters
handler:nil];