2

I'm looking for a drop in solution to add a Facebook and Twitter share button option to my app. I've googled this of course, and found shareKit but it's non-ARC so just throws lots of errors, which is of no use to me. Any other options? they need to be ARC compatible.

I want a SDK that I can drop in, throw in the App ID's and be done.

Phil
  • 2,995
  • 6
  • 40
  • 67

3 Answers3

3

If you want simple sharing, the following can be used for Twitter and Facebook:

if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter]) {
    SLComposeViewController *slComposeViewController = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];

    [slComposeViewController setInitialText:@"Your text"];
    [slComposeViewController addImage:[UIImage imageNamed:@"NameOfImage"]];
    [self presentViewController:slComposeViewController animated:YES completion:nil];
} else {
    //Show alert or in some way handle the fact that the device does not support this feature
}

For Facebook, simply replace SLServiceTypeTwitter with SLServiceTypeFacebook. The "Social" framework must be imported :-)

Jorn
  • 1,054
  • 9
  • 25
1

You can use UIActivityViewController:

NSArray * activityItems = activityItems = @[@"title", [NSURL URLWithString:@"urlstring"]];
    UIActivityViewController *activityController = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:nil];
    [self presentViewController:activityController animated:YES completion:nil];

References : https://developer.apple.com/library/ios/documentation/uikit/reference/UIActivityViewController_Class/Reference/Reference.html

0

Yes use the native iOS sharing dialog: UIActivityViewController

rckoenes
  • 69,092
  • 8
  • 134
  • 166