Last active
December 17, 2015 16:58
-
-
Save YGeorge/5642258 to your computer and use it in GitHub Desktop.
Facebook for iOS 5 and 6
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
- (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