Skip to content

Instantly share code, notes, and snippets.

@alansparrow
Created April 29, 2014 16:30
Show Gist options
  • Save alansparrow/11405425 to your computer and use it in GitHub Desktop.
Save alansparrow/11405425 to your computer and use it in GitHub Desktop.
iOS facebook share
if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook])
{
SLComposeViewController *facebookSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
[facebookSheet setInitialText:@"Facebooking from my own app: http://www.google.com! :)"];
NSString *gameURL = @"http://www.google.com";
[facebookSheet addURL:[NSURL URLWithString:gameURL]];
[[CCDirector sharedDirector] presentViewController:facebookSheet animated:NO completion:nil];
NSLog(@"Twitter1");
}
else
{
UIAlertView *alertView = [[UIAlertView alloc]
initWithTitle:@"Sorry"
message:@"You can't share right now, make sure your device has an internet connection and you have at least one Facebook account setup"
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alertView show];
NSLog(@"Twitter2");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment