How to post to Facebook and Twitter using Social Framework

It is extremely simple to bring up Facebook and Twitter Sheets in your app using the Social Framework.

Once imported you can create a new instance of SLComposeViewController, initialise it with text, an image and a URL, and present it modally from your own view controller.

Screen Shot 2013-12-06 at 18.50.57

You don’t have to specify anything other than which service you’d like to use, in which case the presented sheet will be blank. Here we bring up a tweet sheet (i.e. Post to Twitter dialogue):

And here we specify all three values for a post to Facebook:

Available service types are

– SLServiceTypeFacebook
– SLServiceTypeTwitter
– SLServiceTypeSinaWeibo
– SLServiceTypeTencentWeibo

You can test if a service is available using the isAvailableForService method (which always returns YES on the simulator, and only gives accurate results on a real device):

About Jay Versluis

Jay is a medical miracle known as a Super Survivor. He runs two YouTube channels, five websites and several podcast feeds. To see what else he's up to, and to support him on his mission to make the world a better place, check out his Patreon Campaign.

Add your voice!