1.10. Presenting Sharing Options with UIActivityViewController
Problem
You want to be able to allow your users to share content inside your apps with their friends, through an interface similar to that shown in Figure 1-27 that provides different sharing options available in iOS, such as Facebook and Twitter.

Figure 1-27. The activity view controller displayed on an iOS device
Solution
Create an instance of the UIActivityViewController class and share your
content through this class, as we will see in the Discussion section of
this recipe.
Note
The instances of UIActivityViewController must be presented
modally on the iPhone and inside a popover on an iPad. For more
information about popovers, refer to Recipe 1.29.
Discussion
There are many sharing options inside iOS, all built into the core of the OS. For instance, Facebook and Twitter integration is now an integral part of the core of iOS, and you can share pretty much any content from anywhere you want. Third-party apps like ours can also use all the sharing functionalities available in iOS without having to think about the low-level details of these services and how iOS provides these sharing options. The beauty of this whole thing is that you mention what you want to share, and iOS will pick the sharing options that are capable of handling those items. For instance, if you want to share images and text, iOS will display many more items ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access