Skip to content

Instantly share code, notes, and snippets.

@spraveenk91
Last active August 29, 2015 14:02
Show Gist options
  • Save spraveenk91/70103e6c21db00bd17bd to your computer and use it in GitHub Desktop.
Save spraveenk91/70103e6c21db00bd17bd to your computer and use it in GitHub Desktop.
Facebook info.
- (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