Lesson 28

Social Media Integration

Social media integration is not something that most apps can ignore. These days, social media integration in apps is the norm rather than the exception. Fortunately for you, Apple has integrated support for Facebook Twitter, Sina Webo, and Tecent Webo into iOS 9. Posting to social media services has never been easier!

In this lesson, you learn to integrate the Social framework in your iOS apps and allow the user to share a post on Facebook and Twitter from your apps. You can build more complex clients that can access the entire Facebook/Twitter API, but this topic is beyond the scope of this book.

The Social framework is not included in any of the standard iOS project templates that you use when creating a new project. You will need to add a reference to this framework manually. You can do this from the Project Settings page in Xcode. Select the project node in the project navigator to display the settings page. On the settings page, select the build target and switch to the Build Phases tab. Click the plus (+) button under the Link Binary With Libraries category and select Social.framework from the list of available frameworks (see Figure 28.1).

Screenshot of Finished running SocialTest of iPhone 6, with the menu SocialTest, Target SocialTest and plus symbol encircled and numbered 1,2, and 3.

Figure 28.1

The Share Sheet

The Social framework provides a share sheet that you should use in your apps if all you want is a simple “share” feature. The share sheet is an instance of the SLComposeViewController ...

Get Swift iOS 24-Hour Trainer now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.