Created
November 29, 2013 10:55
-
-
Save miguel12345/7704193 to your computer and use it in GitHub Desktop.
Facebook flow
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| - (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