Skip to content

Instantly share code, notes, and snippets.

@miguel12345
Created November 29, 2013 10:55
Show Gist options
  • Select an option

  • Save miguel12345/7704193 to your computer and use it in GitHub Desktop.

Select an option

Save miguel12345/7704193 to your computer and use it in GitHub Desktop.
Facebook flow
- (void)sessionStateChanged:(FBSession *)session
state:(FBSessionState) state
error:(NSError *)error
{
switch (state) {
case FBSessionStateOpen: {
//open!
}
break;
case FBSessionStateClosed:
case FBSessionStateClosedLoginFailed:
// Once the user has logged in, we want them to
// be looking at the root view.
break;
default:
break;
}
if (error) {
//error
}
}
- (void)openSession
{
[FBSession openActiveSessionWithReadPermissions:@[@"email"]
allowLoginUI:YES
completionHandler:
^(FBSession *session,
FBSessionState state, NSError *error) {
[self sessionStateChanged:session state:state error:error];
}];
}
//application:didFinishLaunchingWithOptions
if (FBSession.activeSession.state == FBSessionStateCreatedTokenLoaded) {
// Yes, so just open the session (this won't display any UX).
[self openSession];
} else {
// No, display the login page.
[self showLoginView];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment