Skip to content

Instantly share code, notes, and snippets.

@kenshin03
Created April 30, 2013 08:53
Show Gist options
  • Save kenshin03/5487487 to your computer and use it in GitHub Desktop.
Save kenshin03/5487487 to your computer and use it in GitHub Desktop.
Facebook authentication with ACAccountType
NSDictionary * facebookOptions = @{ACFacebookAppIdKey:kPSHFacebookAppID,
ACFacebookPermissionsKey: @[@"email", @"publish_stream", @"read_stream", @"user_photos"],
ACFacebookAudienceKey:ACFacebookAudienceFriends};
ACAccountType * facebookAccountType = [self.accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];
[self.accountStore requestAccessToAccountsWithType:facebookAccountType options:facebookOptions
completion: ^(BOOL granted, NSError *error) {
NSLog(@"granted: %i", granted);
if (granted) {
NSArray *accounts = [self.accountStore accountsWithAccountType:facebookAccountType];
NSLog(@"accounts: %@", accounts);
//it will always be the last object with SSO
self.facebookAccount = [accounts lastObject];
success();
} else {
// error handling
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment