本文介绍了我们可以以编程方式注销Facebook吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有Facebook登录我的iphone应用程序使用Facebook sdk-3.1。登录后,它将进入我的应用程序,那里,我没有给任何注销按钮.so,当我们点击按钮登录与我,我会得到以前的用户Facebook帐户。



为了解决这个问题,我给了按钮注销。



我如何以编程方式注销Facebook点击按钮



正在提供这样的登录

   - (IBAction)登录:(id)sender 
{

appDelegate =(AppDelegate *)[[UIApplication sharedApplication] delegate];
appDelegate.getActionForLoginbtn = @LoginwithFB;
[appDelegate openSessionWithAllowLoginUI:YES];



- (BOOL)openSessionWithAllowLoginUI:(BOOL)allowLoginUI {


NSArray * permissions = [[NSArray alloc] initWithObjects :@email,nil];
return [FBSession openActiveSessionWithReadPermissions:permission allowLoginUI:allowLoginUI completionHandler:^(FBSession * session,FBSessionState state,NSError * error){
[self sessionStateChanged:session state:state error:error];
}];
}


解决方案

使用此代码: p>

  if(FBSession.activeSession.isOpen)
{
[FBSession.activeSession closeAndClearTokenInformation];
}


I have facebook login in my iphone app using facebook sdk-3.1 .After login it will get in to my app and there i didnot give any logout button .so,when we click button login with facebook i will get the previous user facebook account .

Inorder to resolve this problem iam giving button logout.

how can i logout facebook programatically on clicking button

am giving login like this

-(IBAction)Login:(id)sender
{

    appDelegate = (AppDelegate *) [[UIApplication sharedApplication] delegate];
     appDelegate.getActionForLoginbtn=@"LoginwithFB";
       [appDelegate openSessionWithAllowLoginUI:YES];
}


-(BOOL)openSessionWithAllowLoginUI:(BOOL)allowLoginUI{


    NSArray *permissions=[[NSArray alloc]initWithObjects:@"email", nil];
    return[FBSession openActiveSessionWithReadPermissions:permissions allowLoginUI:allowLoginUI completionHandler:^(FBSession *session, FBSessionState state, NSError *error) {
        [self sessionStateChanged:session state:state error:error];
    }];
}
解决方案

Use this code :

if (FBSession.activeSession.isOpen)
    {
        [FBSession.activeSession closeAndClearTokenInformation];
    }

这篇关于我们可以以编程方式注销Facebook吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 19:03