Search code examples
iosfacebookfacebook-graph-apisharesharekit

How to share an image & text to Facebook from my iOS App.


I have a native iOS App that I would like to share a Graph & Text to Facebook from.

I don't have any experience on this so just wanted to get your thoughts. I've just checked 'ShareKit' and am not sure if it is the way to go. I think there is a native 'Share' option for iOS as well. So which one is better?

Any ideas, docs, keywords, links?

Thanks, Ervin


Solution

  • You can use Apple's SLComposeViewController Class which includes sharing text and pictures to Facebook, Twitter and Weibo. This class is actually one of the easier ones to understand and learn.

    There is a Ray Wenderlich tutorial on this class on how to post to Twitter but you can very easily change this line of code to go from Twitter to Facebook.

    SLComposeViewController *tweetSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];
    

    to:

    SLComposeViewController *tweetSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
    

    Also try Google for 'SLComposeViewController tutorial' if you don't like the above one.