开发者

iPhone: How to save session using Facebook Graph api

Im relatively new to iPhone development and Im trying to implement Facebook functions in my app. I tried the Facebook connect DemoApp, but it doesn't seem to save my session. I have to login everytime I restart my app. How do I implement session saving in my app开发者_StackOverflow社区? I have searched a lot but still haven't found a simple way to do this. Thanks


You need to request "offline_access" permission. Otherwise your token expires and needs to be refreshed with a new login. If you get offline permission, the token you're given is good until the graph client is explicitly logged out.


Have a look on this [_session resume]; in your FBLoginDialog.m file of the FBConnect....you will find that in this method.This one is responsible for that

- (void)request:(FBRequest*)request didLoad:(id)result {

}

See that is there or not ....also take help from Facebook Connect Tutorial

Good Luck!


The facebook iPhone api automatically saves the session. You simply have to call [session resume]; after alloc'ing and init'ing an FBSession object. If there was nothing to load nothing will happen.


session save and session resume seems to have been removed from the latest facebook connect iphone sdk. In fact where in the old sdk access to the session object was the primary way to access facebook, in the new sdk its all through the 'facebook' class. I have seen games that use the new sdk saving and restoring the session though, so I know its possible, wish I could tell you how it works.

Alright scratch all that, I figured out how to do it with the new SDK, you can save the entire url passed into your applications openurl into the plist, then the next time your app reboots it can read that string and pass it into the facebook without needing to use the authorize routine.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜