S.P.
S.P.

Reputation: 5435

fbconnect logout is not working perfectly

i have integrated Fbconnect in LoginViewController.I want to logout the session from another view controller .. How i can do this ?

I tried this ..

LoginViewController *obj1 = [[LoginViewController alloc] init];     
[obj1._session logout];
[obj1._session.delegates removeObject: self];

It removing the session..But wen i go to LoginViewController the button is showing logout.But when i quit application and run it, the image is updated.

In LoginViewController i have

@interface LoginViewController : UIViewController  <FBDialogDelegate, FBSessionDelegate, FBRequestDelegate>{

    IBOutlet UITextField *txtUsername;
    IBOutlet UITextField *txtPassword;
    IBOutlet UILabel *lblMessage;
    IBOutlet FBLoginButton* _loginButton;
    FBSession* _session;

}

@property (nonatomic, retain) FBSession *_session;

and am synthesizing it @synthesize _session;

....What else i have to do ?

Somebody please help me..am very new to Iphone application and objective c

Upvotes: 1

Views: 2324

Answers (2)

Saurabh
Saurabh

Reputation: 331

-(void)clickfb:(id)sender {

NSHTTPCookieStorage* cookies = [NSHTTPCookieStorage sharedHTTPCookieStorage];
for (NSHTTPCookie* cookie in
     [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookies]) {
    [cookies deleteCookie:cookie];
}

 [self showLoggedOut:YES];

}

  • (void) showLoggedOut:(BOOL)clearInfo { //[self.navigationController setNavigationBarHidden:YES animated:NO]; // // Remove saved authorization information if it exists and it is // // ok to clear it (logout, session invalid, app unauthorized) NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; if (clearInfo && [defaults objectForKey:@"FBAccessTokenKey"]) { [defaults removeObjectForKey:@"FBAccessTokenKey"]; [defaults removeObjectForKey:@"FBExpirationDateKey"]; [defaults synchronize]; // // // Nil out the session variables to prevent // // the app from thinking there is a valid session AppDelegate *delegate = (AppDelegate *) [[UIApplication sharedApplication] delegate]; if (nil != [[delegate facebook] accessToken]) { [delegate facebook].accessToken = nil; } if (nil != [[delegate facebook] expirationDate]) { [delegate facebook].expirationDate = nil; } }

}

Upvotes: 0

S.P.
S.P.

Reputation: 5435

I got the answer ..My Friend helped me.. i want to share it...

simply

import "FBConnect.h"

in ur second view controller

then .......

FBSession *session = [FBSession session]; [session logout];

It works fine

Upvotes: 1

Related Questions