Inspired Questions: Simple Social Sharing in iOS

While building Inspired Questions, I needed a way to share content on Facebook, Twitter, E-mail, and via Messages, basically, the whole suite of easily integrated items since iOS 6+. To make it easy for myself in the future, and anyone else seeking to make a more social app, I captured a standalone class called SimpleSocia as a GitHub gist. Here is a brief introduction:

Simple Social

SimpleSocial is an Objective-C class that provides a means for finding if services are available. To check if a service is available, just call one of the class functions:

Twitter and Facebook are only available if the device is iOS 6.0+ and the user has logged into the service using the Settings app. Mail depends on being logged into some Mail provider. I never found a permutation where SMS was not available; it just redirects to Messages on the device.

It's always best to conditionally show the sharing feature if the service is available. For instance, if you have a "Share to Facebook" button, you can set the hidden field based on the value returned by the "isFacebookAvailable" function. Once you have confirmed a service is available, you can simple make an instance of the SimpleSocial class, then call the relevant dialog function.

For instance, let's assume we have a UIViewController subclass that wants to show a Facebook dialog when a button is pressed:

While this is certainly one of the more terse gists I've saved for Objective-C, it is probably one of the more likely to be referenced again given the prolific need for social integration in mobile apps. New variations of the dialogs that provide photo-sharing are  likely for the future, assuming I can find an excuse to evolve this simple class a little further.