Note that there are some explanatory texts on larger screens.

plurals
  1. POFacebook ios logout method does not work
    primarykey
    data
    text
    <p>I have used this method for logout facebook in app</p> <pre><code>- (void)fbDidLogout { // Remove saved authorization information if it exists NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; if ([defaults objectForKey:@"FBAccessTokenKey"]) { [defaults removeObjectForKey:@"FBAccessTokenKey"]; [defaults removeObjectForKey:@"FBExpirationDateKey"]; [defaults synchronize]; } NSLog(@"logout success!"); } </code></pre> <p>This method has been invoked, but when I relaunch app the facebook still know about my latest authorization.</p> <p>My full implementation</p> <p>I create singleton object for facebook instance.</p> <p>this is my manager .h</p> <pre><code>#import &lt;Foundation/Foundation.h&gt; #import "FBConnect.h" @interface FacebookManager : NSObject &lt;FBSessionDelegate&gt; { Facebook *facebook; } @property (nonatomic, strong) Facebook *facebook; + (FacebookManager *)sharedInstance; - (void)initWithAppID:(NSString *)appID; @end </code></pre> <p>this is singleton facebookmanager .m</p> <pre><code>#import "FacebookManager.h" @implementation FacebookManager @synthesize facebook; static FacebookManager *_sharedInstance = nil; + (FacebookManager *)sharedInstance { @synchronized(self) { if (!_sharedInstance) { _sharedInstance = [[FacebookManager alloc] init]; } } return _sharedInstance; } - (void)initWithAppID:(NSString *)appID { facebook = [[Facebook alloc] initWithAppId:appID andDelegate:self]; NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; if ([defaults objectForKey:@"FBAccessTokenKey"] &amp;&amp; [defaults objectForKey:@"FBExpirationDateKey"]) { facebook.accessToken = [defaults objectForKey:@"FBAccessTokenKey"]; facebook.expirationDate = [defaults objectForKey:@"FBExpirationDateKey"]; } if (![facebook isSessionValid]) { [facebook authorize:nil]; } } - (void)fbDidLogout { // Remove saved authorization information if it exists NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; if ([defaults objectForKey:@"FBAccessTokenKey"]) { [defaults removeObjectForKey:@"FBAccessTokenKey"]; [defaults removeObjectForKey:@"FBExpirationDateKey"]; [defaults synchronize]; } NSLog(@"logout success!"); } @end </code></pre> <p>in appDelegate I make next:</p> <pre><code>- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { fbManager = [FacebookManager sharedInstance]; [fbManager initWithAppID:@"myappid"]; ... (some other code) } </code></pre> <p>also add this code to app delegate:</p> <pre><code>- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url { return [fbManager.facebook handleOpenURL:url]; } - (void)fbDidLogin { NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; [defaults setObject:[fbManager.facebook accessToken] forKey:@"FBAccessTokenKey"]; [defaults setObject:[fbManager.facebook expirationDate] forKey:@"FBExpirationDateKey"]; [defaults synchronize]; } </code></pre> <p>In other view controller I call this method for logout:</p> <pre><code>- (IBAction)logoutFacebook:(id)sender { FacebookManager *fbManager = [FacebookManager sharedInstance]; [fbManager.facebook logout]; } </code></pre> <p>also in plist I have add needed url scheme.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload