iphone - facebook-ios-sdk logout -


i building basic app school gets info facebook using facebook-ios-sdk. however, when log out of app, not give me option log in, in demo facebook. checking see if sessions still valid, , comes out invalid. problem. here code have. appreciated.

- (void)viewdidload {       _facebook = [[facebook alloc] init];        if ([_facebook issessionvalid] == no) {        //show proper buttons login         loginbutton.hidden = no;         logoutbutton.hidden = yes;        }       else {      //show proper buttons logout         loginbutton.hidden = yes;         logoutbutton.hidden = no;     }   } 

that check whether logged in or not. have proper buttons showing, code above returning session invalid. here functions call log in or out:

- (void)login {      [_facebook authorize:kappid permissions:_permissions delegate:self]; }  /** * invalidate access token , clear cookie. */ - (void)logout {      [_facebook logout:self]; } 

the facebook object says has no valid session because accesstoken and/or expirationdate nil. that's because doesn't persist them itself. need record accesstoken , expirationdate handling login in fbsessiondelegate's fbdidlogin method.

- (void)fbdidlogin {     [[nsuserdefaults standarduserdefaults] setvalue: _facebook.accesstoken forkey: @"access_token"];     [[nsuserdefaults standarduserdefaults] setvalue: _facebook.expirationdate forkey: @"expiration_date"]; } 

use nsuserdefaults, example, persist values device. then, every time alloc , init _facebook object, set accesstoken , expirationdate values stored in nsuserdefaults.

that should fix facebook object saying issessionvalid = no always. other problem, have same 1 :(


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -