Created
April 30, 2013 08:53
-
-
Save kenshin03/5487487 to your computer and use it in GitHub Desktop.
Facebook authentication with ACAccountType
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
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