我想实现与朋友粉碎游戏中相同的Facebook 身份验证概念。
在此,如果用户通过 iOS facebook 应用程序登录 facebook,则它只要求用户访问基本个人资料信息。从上面的链接有一些步骤可以在朋友粉碎游戏中实现这个概念。我想在我的本机应用程序中添加它。但无法知道如何做到这一点。如果有人对此有所了解,请帮助我。我会非常感谢你。
我想实现与朋友粉碎游戏中相同的Facebook 身份验证概念。
在此,如果用户通过 iOS facebook 应用程序登录 facebook,则它只要求用户访问基本个人资料信息。从上面的链接有一些步骤可以在朋友粉碎游戏中实现这个概念。我想在我的本机应用程序中添加它。但无法知道如何做到这一点。如果有人对此有所了解,请帮助我。我会非常感谢你。
When logging in, using:
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)
If your "permissions" array is nil, it only requests the Basic access to the user profile. If you need other permissions, just add the wanted ones on the permissions array. The valid values can be found here: https://developers.facebook.com/docs/howtos/ios-6/, like "email", "user_birthday", "user_location", "user_about_me" etc.
Note that when logging in / requesting Read Permissions you CANNOT requests for publishing permissions. That must be performed later, after logging in. You can check if the user already has the requested permission (as the Publish one) and, if he/she has it, publish the content; if not, request it:
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
(...)
}
More info about publishing content, look up "requestNewPublishPermissions" here: https://developers.facebook.com/docs/tutorials/ios-sdk-tutorial/publish-open-graph-story/