开发者

fbconnect logout is not working perfectly

i have integrated Fbconnect in LoginViewController.I want to logout the s开发者_运维技巧ession 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


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


-(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; } }

}

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜