Andres
Andres

Reputation: 11747

Need to post to facebook and twitter from an ios app

I've been doing some research on how to post to fb and to twitter... I know there is a library called Sharekit and I also know I can post using the new iOS6 feature SLComposeViewController... I just need to post a text, that's all... It's not necessary that the user can edit the message...

I need some advice, what would you use?

Upvotes: 0

Views: 850

Answers (2)

MasterRazer
MasterRazer

Reputation: 1377

Try this one:

- (IBAction)share:(id)sender
{
    NSString *text = @"Your message";
    UIImage *image = [UIImage imageNamed:@"yourimage.png"];
    NSArray *items = [NSArray arrayWithObjects:text,image , nil];
    UIActivityViewController *avc = [[avcClass alloc] initWithActivityItems:items applicationActivities:nil];
    avc.excludedActivityTypes = @[UIActivityTypePrint, UIActivityTypeCopyToPasteboard, UIActivityTypeAssignToContact,UIActivityTypeSaveToCameraRoll, UIActivityTypeMessage, UIActivityTypeMail];
    [self presentViewController:avc animated:YES completion:nil];
}

This should work for you. Just set the NSString and if you want an image.

No frameworks needed!

Upvotes: 1

Rob
Rob

Reputation: 437482

If you're ok supporting only iOS6, SLComposeViewController is probably easiest. On the Facebook side, you lose nice little features offered via the Facebook SDK for iOS (e.g., the ability to have the Facebook post bear some indication that it came from your app, the graceful inclusion of both images and URLs, etc.).

Bottom line, if you're ok with iOS6-only and you want to keep it simple, SLComposeViewController is probably easiest and can do both Twitter and Facebook. If you want to make the most of Facebook or if you have to support iOS 5, you really have to pursue the Facebook SDK, but it takes a little more code. On the Twitter side, if you need to support iOS 5, then you need to use TWTweetComposeViewController.

Upvotes: 2

Related Questions