Skip to content

Instantly share code, notes, and snippets.

@YGeorge
Last active December 17, 2015 16:58
Show Gist options
  • Save YGeorge/5642258 to your computer and use it in GitHub Desktop.
Save YGeorge/5642258 to your computer and use it in GitHub Desktop.
Facebook for iOS 5 and 6
- (IBAction)fbBtnTouchUp:(id)sender {
if(NSClassFromString(@"SLComposeViewController") != nil) {
if([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) {
SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
[controller setInitialText:self.post.title];
[controller addURL:[NSURL URLWithString:self.post.url]];
[self presentViewController:controller animated:YES completion:Nil];
}
else
{
UIAlertView *alertView = [[UIAlertView alloc]
initWithTitle:@"Sorry"
message:@"There are not Facebook accounts configured yet"
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alertView show];
}
}
else{
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
@"198914023594250", @"app_id",
self.post.url, @"link",
@"Fuerza", @"name",
@"Fuerza.com", @"caption",
self.post.title, @"description",
nil];
[FBWebDialogs presentFeedDialogModallyWithSession:nil parameters:params handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error) {
if (result == FBWebDialogResultDialogCompleted) {
UIAlertView *alertView = [[UIAlertView alloc]
initWithTitle:@"Success"
message:@"Sharing completed!"
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alertView show];
}
}];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment