Created
May 17, 2013 04:49
-
-
Save evadne/5596987 to your computer and use it in GitHub Desktop.
Correctly Handling ACErrorAccountNotFound
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
ACAccountStore * const accountStore = [ACAccountStore new]; | |
ACAccountType * const accountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook]; | |
[accountStore requestAccessToAccountsWithType:accountType options:@{ | |
ACFacebookAppIdKey: @"-snip-" | |
} completion:^(BOOL granted, NSError *error) { | |
if (!granted) { | |
switch (error.code) { | |
case ACErrorAccountNotFound: { | |
dispatch_async(dispatch_get_main_queue(), ^{ | |
SLComposeViewController *composeViewController = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook]; | |
[self presentViewController:composeViewController animated:NO completion:^{ | |
[composeViewController dismissViewControllerAnimated:NO completion:nil]; | |
}]; | |
}); | |
break; | |
} | |
default: { | |
NSLog(@"%s %x %@", __PRETTY_FUNCTION__, granted, error); | |
[[[UIAlertView alloc] initWithTitle:@"D:" message:error.localizedFailureReason delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil] show]; | |
break; | |
} | |
} | |
return; | |
} | |
}]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks! :)