Last active
August 29, 2015 14:02
-
-
Save spraveenk91/70103e6c21db00bd17bd to your computer and use it in GitHub Desktop.
Facebook info.
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
- (IBAction)getFacebookUserInfo:(id)sender { | |
NSArray *permissions = [NSArray arrayWithObjects:@"email", @"basic_info", nil]; | |
[FBSession openActiveSessionWithReadPermissions:permissions allowLoginUI:YES completionHandler:^(FBSession *session, FBSessionState status, NSError *error) | |
{ | |
/* handle success + failure in block */ | |
if (!error) { | |
[self me]; | |
} else { | |
NSLog(@"Session ended"); | |
[self hideProgressHud]; | |
} | |
}]; | |
} | |
--- | |
- (void)me { | |
if (FBSession.activeSession.isOpen) { | |
[[FBRequest requestForMe] startWithCompletionHandler: ^(FBRequestConnection *connection, NSDictionary<FBGraphUser> *user, NSError *error) { | |
if (!error) { | |
NSLog(@"Username : %@", [user objectForKey:@"username"]); | |
} else { | |
NSLog(@"Error: %@", error.localizedDescription); | |
[self hideProgressHud]; | |
} | |
}]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment