![](/img/trans.png)
[英]iOS Facebook SDK share photo and after logout from Facebook app
[英]Logout from Facebook after a share with Facebook iOS SDK
我正在構建一個iPad應用程序,用戶可以在其中將圖像發布到他/她的時間軸上。 這些iPad是可出租的,因此共享完成后應注銷用戶。
我已經實現了iOS Facebook登錄,因此將用戶重定向到Safari進行登錄。 共享之后,我清理了所有令牌,並在我的應用程序中破壞了該會話,但是當我隨后進入Safari時,用戶仍然登錄。
有沒有辦法確保用戶到處注銷?
親切的問候,弗雷德里克
我過去做過類似的事情。 在此流程中,任何持有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];
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.