开发者

Resuming sessions in FBConnect's new Graph API

开发者 https://www.devze.com 2023-02-22 06:50 出处:网络
I have scoured the internet looking for an answer to this question and can\'t find one. Using ONLY the new graph API for FBConnect\'s newest SDK how do you \"resume a session?\"

I have scoured the internet looking for an answer to this question and can't find one.

Using ONLY the new graph API for FBConnect's newest SDK how do you "resume a session?"

In the old SDK and API, you could call something like [session resume]; and that would resume your session. I can't find any equivalent that works with the new SDK/API.

[session resume]; does not work.

[session isSessionValid]; will test开发者_如何学Go the validity of the session, but will not resume it.

Right now, the only thing I think of to do is have the user go to the authorization page for the app each time they use it. However, this is annoying as after the user initially authorizes the app, each time it returns to the page it states: "You have already authorized [name of app] app" and then you can hit okay, and it sends you back to the app with a valid session. *I have seen other posts around the internet where other developers have had to use this same process because they couldn't find the answer either.

If anybody has any answers, please share them. However, because this question is specifically for the new graph API and new SDK, answers that include code/instructions for the old API or SDK will be deleted.


In the fbdidLogin do

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

Every time your app loads recover these keys and create a facebook object with them:

facebook = [[[Facebook alloc] initWithAppId:@"yourappid"] retain];
facebook.accessToken    = [[NSUserDefaults standardUserDefaults] stringForKey:@"AccessToken"];
facebook.expirationDate = (NSDate *) [[NSUserDefaults standardUserDefaults] objectForKey:@"ExpirationDate"];

Use then the isSessionValid on that object. If it is valid, just go ahead and do your graph API business with that very same object. If not then do the normal authorize. It works great for me. Hope it helps.

0

精彩评论

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

关注公众号