开发者

how to tell whether Facebook is still loggin or not?

开发者 https://www.devze.com 2023-01-24 04:07 出处:网络
After _facebook = [[Facebook alloc] init]; and [_facebook authorize:kAppId permissions:_permissions delegate:self];

After

 _facebook = [[Facebook alloc] init];

and

 [_facebook authorize:kAppId permissions:_permissions delegate:self];

How can I tell whether the _facebook is (s开发者_开发知识库till) logged-in/valid to do further [_facebook requestWithMethodName: ...]?

Or should I just simply [_facebook authorize:...] again and again? Thanks!


I was having the same issue which i solved with the solution of another Member from here, dont know link exactly. but here's the solution

When you are logged into the facebook

    [[NSUserDefaults standardUserDefaults] setObject:self.facebook.accessToken forKey:@"AccessToken"];
[[NSUserDefaults standardUserDefaults] setObject:self.facebook.expirationDate forKey:@"ExpirationDate"];

In next View Controller, where you want to use the facebook with same session

_facebook.accessToken    = [[NSUserDefaults standardUserDefaults] stringForKey:@"AccessToken"];
_facebook.expirationDate = (NSDate *) [[NSUserDefaults standardUserDefaults] objectForKey:@"ExpirationDate"];
if ([_facebook isSessionValid] == NO) {
    //[_facebook authorize:kAppId permissions:self.permissions delegate:self]; //Create new facebook instance
}

Let me know if i put something which does not work for you.

Thanks

0

精彩评论

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