在ios app.cannot切换用户中,facebook没有正确注销 [英] facebook does not logout properly in ios app.cannot switch users
问题描述
我正在使用fb sdk提供的Facebook登录按钮,在我的应用程序中实现Facebook登录。当我注销Facebook按钮确实会改回登录。但是当我点击它,Safari浏览器应用程序打开显示你有alreay授权的应用程序点击确认或取消。实际上,我需要Facebook登录和密码屏幕在这里。我不能切换用户,直到我重置模拟器。以每次我注销以编程方式重新设置safari内容,以便
i am using the facebook login button provided by the fb sdk for implementing the facebook login in my app.When i am logging out the facebook button does change back to login again.but when i click on it,the safari app opens showing "you have alreay authorised the app"click confirm or cancel.Actually i needed the facebook login and password screen here.I cannot switch user until i reset the simulator.how to reset the contents in safari programmatically each time i logout so that the login screen is shown each time.
请注意,当我手动清除safari的网站数据时,会再次显示登录页面。可以通过编程方式。
Please note that when i clear the website data of safari manually it shows the login page again.can it be done programmatically.
我用于登录的代码如下
//creating the login button
FBLoginView *loginView =
[[FBLoginView alloc] initWithReadPermissions:
@[@"public_profile", @"email", @"user_friends"]];
loginView.frame=CGRectMake(50, 500, 225, 55);
loginView.delegate=self;
[self.view addSubview:loginView];
//delegate method when logged in
- (void)loginViewFetchedUserInfo:(FBLoginView *)loginView
user:(id<FBGraphUser>)user {
NSUserDefaults *defaults=[NSUserDefaults standardUserDefaults];
[defaults setObject:[user objectForKey:@"id"] forKey:@"LoggedInUserID"] ;
[self checkandsaveNewUserInBackend:user];
[self performSegueWithIdentifier:@"Login" sender:self];
}
//logout code
- (IBAction)logoutButtonPressed:(id)sender {
[FBSession.activeSession closeAndClearTokenInformation];
[self.navigationController popToRootViewControllerAnimated:YES];
}
推荐答案
在
//logout code
- (IBAction)logoutButtonPressed:(id)sender {
使用以下代码
if (FBSession.activeSession.state == FBSessionStateOpen
|| FBSession.activeSession.state == FBSessionStateOpenTokenExtended) {
// Close the session and remove the access token from the cache
// The session state handler (in the app delegate) will be called automatically
[FBSession.activeSession closeAndClearTokenInformation];
// If the session state is not any of the two "open" states when the button is clicked
} else {
// Open a session showing the user the login UI
// You must ALWAYS ask for public_profile permissions when opening a session
[FBSession openActiveSessionWithReadPermissions:@[@"public_profile"]
allowLoginUI:YES
completionHandler:
^(FBSession *session, FBSessionState state, NSError *error) {
}];
}
这篇关于在ios app.cannot切换用户中,facebook没有正确注销的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!