简体   繁体   English

用多个用户登录Facebook

[英]facebook login with multiple users

I have integrate facebook api and i easily login but after logout my app from Facebook when i again login then is shows you have already authorised and come to the app home page.But I want if I logout account then next time again require username and password to use the different user. 我已经集成了Facebook api,我很容易登录,但是从Facebook注销我的应用程序后再次登录时显示您已经被授权并进入应用程序主页。但是我想如果我注销帐户然后再次要求用户名和密码使用其他用户。

I already yes ,status and review option from Facebook developers account to live but yet this problem occurs. 我已经同意了,状态和来自Facebook开发人员帐户的复审选项可以使用,但是仍然出现此问题。

your logout is fine I think you are not clear the current session of facebook, when you click the logout button You have to implement the two methods for logout. 您的注销很好,我认为您无法清除当前的Facebook会话,当您单击注销按钮时,您必须实现两种注销方法。

FBSDKLoginManager *loginManager = [[FBSDKLoginManager alloc] init];
[loginManager logOut];

set the currentAccessToken to nil 将currentAccessToken设置为nil

[FBSDKAccessToken setCurrentAccessToken:nil];
[FBSDKProfile setCurrentProfile:nil];

for loginview 用于loginview

- (void)loginButtonDidLogOut:(FBSDKLoginButton *)loginButton { 

   // do like delete the permission, this means you fully logout from facebook

    [[[FBSDKGraphRequest alloc] initWithGraphPath:@"me/permissions/"
   parameters:nil
   HTTPMethod:@"DELETE"]
startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
     NSLog(@"deleted successfully");
}];


    } 

the above method clear the current session , when you click the facebook button again it ask the new permission for new user. 上面的方法清除当前会话,当您再次单击Facebook按钮时,它将询问新用户的新权限。

if you want to clear the safari cookies also use 如果您想清除Safari Cookie,也可以使用

Only clears the local FB session information but not the Safari cookies. 仅清除本地FB会话信息,而不清除Safari cookie。 So, after I log in the user, I clear the Safari cookies: 因此,登录用户后,我将清除Safari cookie:

NSLog(@"Logged out facebook");
 NSHTTPCookie *cookie;
 NSHTTPCookieStorage *storage = [NSHTTPCookieStorage sharedHTTPCookieStorage];
for (cookie in [storage cookies])
 {
NSString* domainName = [cookie domain];
NSRange domainRange = [domainName rangeOfString:@"facebook"];
if(domainRange.length > 0)
{
   [storage deleteCookie:cookie];
}
}

if you want to access the multiple user in the same time see sample app name Scrumptious you can get this app from here 如果您想同时访问多个用户,请参阅示例应用程序名称Scrumptious,您可以从此处获取此应用程序

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM