允许Facebook个人资料权限
问题描述:
我想实现与朋友smasher游戏中相同的Facebook authentication概念。允许Facebook个人资料权限
在此如果用户通过iOS的Facebook应用程序登录Facebook,那么它只会要求用户访问基本的个人资料信息。从上面的链接有步骤来实现这个概念在朋友smasher游戏。我想在我的本地应用程序中添加此项。但无法知道如何做到这一点。如果任何人有这方面的知识,请帮助我。我会非常感谢你。
答
登录时,使用:
NSArray *permissions = [[NSArray alloc] initWithObjects:
@"email",
nil];
// Attempt to open the session. If the session is not open, show the user the Facebook login UX
[FBSession openActiveSessionWithReadPermissions:permissions allowLoginUI:true completionHandler:^(FBSession *session,
FBSessionState status,
NSError *error)
如果你的“权限”数组是零,只要求用户配置文件的基本访问。如果您需要其他权限,只需将权限数组添加到想要的权限。有效的值可以在这里找到:https://developers.facebook.com/docs/howtos/ios-6/,如“电子邮件”,“user_birthday”,“user_location”,“user_about_me”等
请注意,当登录/请求读取权限时,您不能请求发布权限。必须在登录后稍后执行。您可以检查用户是否已获得所请求的权限(如发布一个),如果他/她拥有该权限,则发布该内容;如果不是,它要求:
if ([FBSession.activeSession.permissions indexOfObject:@"publish_actions"] == NSNotFound) {
// If the user doesn't have the publishing permission, tries to request it befor sharing
[FBSession.activeSession
requestNewPublishPermissions:[NSArray arrayWithObject:@"publish_actions"]
defaultAudience:FBSessionDefaultAudienceFriends
completionHandler:^(FBSession *session, NSError *error) {
if (!error) {
// Tries to share the content again, assuming we now have the permission
(...)
} else {
// Couldn't get the required Permissions
}
}];
} else {
// If the user already have the permissions, tries to publish the content
(...)
}
关于发布内容,查找“requestNewPublishPermissions”在这里更多信息:https://developers.facebook.com/docs/tutorials/ios-sdk-tutorial/publish-open-graph-story/
你应该试试这里的“入门”部分:https://developers.facebook.com/IOS / – WYS 2013-04-23 11:56:51