Created
October 7, 2013 11:11
-
-
Save leoru/6866165 to your computer and use it in GitHub Desktop.
Facebook openSession
This file contains 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)handleSessionWithCompletion:(void (^)(void))completion { | |
if (FBSession.activeSession.isOpen) { | |
completion(); | |
} else { | |
NSArray *permissions = @[@"user_birthday"]; | |
[FBSession openActiveSessionWithReadPermissions:permissions | |
allowLoginUI:YES completionHandler:^(FBSession *session, | |
FBSessionState status, | |
NSError *error) { | |
if (error) { | |
[SVProgressHUD dismiss]; | |
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" | |
message:error.localizedDescription | |
delegate:nil cancelButtonTitle:@"OK" | |
otherButtonTitles:nil]; | |
[alert show]; | |
} else if (FB_ISSESSIONOPENWITHSTATE(status)) { | |
ALog(@"Facebook expiration date: %@",FBSession.activeSession.accessTokenData.expirationDate); | |
completion(); | |
} | |
}]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment