Reputation: 1420
I have implemented Facebook Connect in my app, and it seems to work fine. I can publish statuses and everything. However, when I quit the app and run it again, the session token seems to have expired or something, because I can't post anymore. But if I authenticate with Facebook again, it shows that permissions have already been granted, then only when the callback to the app is called, can I post again.
What am I doing wrongly?
Upvotes: 0
Views: 555
Reputation: 1986
you should store the accessToken and expireTime of your Facebook object yourself. Restore it after startup and verify via isSessionValid, otherwise reauthorize user. You can use these functions for it:
Call the store function within your fbDidLogin, and the restore function whenever it is appropriate after startup of your app.
-(void)restoreFBAccessToken {
self.facebook.accessToken = [[NSUserDefaults standardUserDefaults] objectForKey:@"fb_accessToken"];
self.facebook.expirationDate = [[NSUserDefaults standardUserDefaults] objectForKey:@"fb_expirationDate"];
}
-(void)storeFBAccessToken {
[[NSUserDefaults standardUserDefaults] setValue:self.facebook.accessToken forKey:@"fb_accessToken"];
[[NSUserDefaults standardUserDefaults] setValue:self.facebook.expirationDate forKey:@"fb_expirationDate"];
[[NSUserDefaults standardUserDefaults] synchronize];
}
Upvotes: 2
Reputation: 7605
Have you made sure to start the session once again when the app is reloaded up?
Upvotes: 0
Reputation: 6448
I'm also using FB Connect in my own app, but in an indirect way. I use it through a third-party open source kit named ShareKit. http://www.getsharekit.com/
As I remember, ShareKit does the job pretty well. It remembers those login information even though the app is shut down.
Since ShareKit is open-source, I suggest you take a look at its code. It should have an answer for you. :-)
Upvotes: 0