我想實現與朋友smasher遊戲中相同的Facebook authentication概念。允許Facebook個人資料權限
在此如果用戶通過iOS的Facebook應用程序登錄Facebook,那麼它只會要求用戶訪問基本的個人資料信息。從上面的鏈接有步驟來實現這個概念在朋友smasher遊戲。我想在我的本地應用程序中添加此項。但無法知道如何做到這一點。如果任何人有這方面的知識,請幫助我。我會非常感謝你。
我想實現與朋友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