Skip to content

Instantly share code, notes, and snippets.

@jagbolanos
Created February 6, 2012 23:45
Show Gist options
  • Save jagbolanos/1755953 to your computer and use it in GitHub Desktop.
Save jagbolanos/1755953 to your computer and use it in GitHub Desktop.
Load Facebook object
+(BOOL) loadSession {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
if (![defaults objectForKey:ACCESS_TOKEN_KEY] ||
![defaults objectForKey:EXPIRATION_DATE_KEY] ||
![defaults objectForKey:FACEBOOK_USER]) {
[Util clearSession];
return NO;
}
Facebook *facebook = [[Util sharedInstance] facebook];
facebook.accessToken = [defaults objectForKey:ACCESS_TOKEN_KEY];
facebook.expirationDate = [defaults objectForKey:EXPIRATION_DATE_KEY];
if (![facebook isSessionValid]) {
[Util clearSession];
return NO;
}
[[Util sharedInstance] setUser:[defaults objectForKey:FACEBOOK_USER]];
NSLog(@"%@", [[[Util sharedInstance] user] objectForKey:@"username"]);
return YES;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment