Share extensions, part the new Extensibility features in iOS 8,are some of the most important additions to the platform since the launch of the App Store. That's right, sharing isn't just for Apple's own services and partners any more. Now, any app can hook into the system-wide Share Sheets and present a way to upload comments, photos, videos, audio, links, and more from within any other app. So, how does it work?
Sharing from the start
Sharing has always been part of iOS. Even on the very first iPhone you could share a photo via Mail. As time went on, more and more sharing options became available for more and more types of data. You could share videos and location, contact cards and website addresses, app and media links, voice memos, and more. And you could do it not only through Apple's own services like Messages but through the services they partnered with and integrated, like Twitter and Facebook, YouTube and Flickr.
Originally, Apple presented sharing options in a simple list. In addition to being rather drab, it didn't scale. With iOS 6, Apple added Share Sheets, a grid of icons that was both more dense and more visually parseable. Share Sheets included both the full-color icons of apps that could be used to share content, like Message or Twitter, and the grayscale icons of actions that could be performed on that content, like Copy or Print.
However, the grid still didn't scale enough and, aside from the color treatments, didn't visually separate sharing options from action options. So, with iOS 7, Apple not only redesigned Share Sheets in keeping with the overall new look and feel, they changed them from a grid to a set of rows. The top row was given over to the colorful, app-based sharing options and the bottom row to the black and white action icons. And both sets could scroll horizontally.
There was now room for more sharing options, but still only those made or integrated by Apple. At least until iOS 8...
How custom sharing works
With iOS 8 and Extensibility, gone are the days when Apple had to make a deal with social networks and laboriously integrate them one and a time into iOS. Now, any app you download from the App Store can hook into the Share Sheets and give you the option to share or upload your content with other members and to the service.
For example, Apple and Pinterest no longer have to come to any special deals or work on any unique implementations. Pinterest can simply add a share extension to their app. That way, when you download it, the Pinterest icon and option will become available in the Share Sheet just like the built-in options.
So, let's say you're in Safari and you see a great new iPhone case on iMore. You can simply tap the Share button, scroll across to Pinterest, and tap the icon to pin it. The sharing extension gets full access to Safari, so you can swipe through all the available images of that iPhone case and pick just exactly the one you want to pin. The extension also gets full, secure access to Pinterest via the Pinterest app, so you can choose just exactly which of your boards you want that iPhone case pinned to.
Because of custom sharing extensions, you also get the ability to customize your sharing options. Scroll all the way to the right on a Share Sheet and you'll see a special "More" icon. Tap it and you're taken to the Activities panel where you can toggle on or off all the sharing options (with the exception of Messages and Mail), and move all of them around into any order you like.
That means, if Pinterest is something you use a lot, you can move it to one of the first few slots. If Facebook is something you use never, you can switch it off and not worry about it taking up space and slowing you down.
The same would hold true for other networks like Google+, options like Mailbox, or online photo, video, or audio services like 500px or Vine. Anything that you can share socially or directly, or upload to an online collection could be made available to you in a share extension.
That makes for much easier, better workflows. Prior to iOS 8, you'd have to copy a URL, go to the social or IM app you wanted to share it from, paste it in, and then go from there. Prior to iOS 8, you'd have to go to the photo or video app you wanted to upload your content to, pull up the camera roll, search for and pick the photos or video you wanted to upload, and then go from there.
With iOS 8 and share extensions, you basically have a plugin that lets you share comments, photos, videos, audio, links, and more right from Safari or Photos or any appropriate apps that hooks into the Share Sheet system. You can share from wherever you are, whenever you have the content in front of you.
Like with widgets and interactive notifications, instead of going somewhere else and hunting around for what you want to do, iOS 8 brings it to you. It's more efficient, it's more convenient, and it's just plain better.
Developing share extensions
Share extensions are a way for developers to take the sharing and uploading features of their apps, package them, and put them into the system-wide Share Sheets so they can be invoked from inside any other appropriate app.
Like other Extensibility features, share extensions are view controllers. Two kinds of share extension view controllers are available to developers. The first is the standard, system-default share sheet look and feel. The second is a custom view controller.
System defaults are both quick to implement and offer a lot of functionality, like image preview, text entry, audience picker, etc. "for free". They also help maintain continuity of experience. Custom sheets are more work but can leverage code from the existing app and better show off a service's branding. That can be useful in continuously, visually reminding someone which service they're sharing to throughout the process.
In addition to view controllers, a display name tells people which app extension they're using. If apps include multiple sharing options, the a display will differentiate those as well.
Activation rules tells the system when to offer a particular app's extension. For example, when photos are selected, the activation rules for a photo app would tell iOS that it should be included in the options. If a web link or block of text is selected, however, the activation rules for a photo app would result in it not being included — the content simply isn't relevant to it.
Social networks, instant messengers, photo sharing services, video sharing services, microblogs, etc. can and will all have different, if sometimes overlapping activation rules. Developers can indicate their activation rules by using a predicate with as simple or as detailed a query string as is needed. Developers can also use condensed rules for even simpler criteria.
For any share extension that uploads content like photos or video, the process has to be run by the system in the background. Since extensions only "live" while they're being displayed, that allows the upload activity to persist for as long as it has to, even after someone has finished using the sharing interface and gone on to do something else.
Performance is just as important in share extensions as they are in other Extensibility feature. Apple encourages developers to keep things lean so interface can be shown quickly. Also, if large files like photos or videos are being accessed, to defer the actual transfer until after the sharing action is completed, so the interface can stay responsive.
There are a number of resources available to aid in all this:
- WWDC 2014 Creating Extensions for iOS and OS X session, Part 1
- Apple (pre-release) Extensibility documentation
Share extensions are designed to provide extra functionality and convenience while still maintain the security- and privacy-first approach of iOS. This is why Extensibility is different than contracts and intents on other platforms, and is broken into several different, discreet bits of functionality like share extensions, action extensions, and photo editing.
iOS apps are "sandboxed" so they can only access their own data unless specific, explicit permission is given by the person using them. That's why apps need to request access to the camera roll, or why you have to tap the "Open in..." button. It makes it harder for malicious apps to do ever get onto the system and into your private data.
With iOS 8 and Extensibility, Apple keeps an app's extensions inside the app's sandbox, but allows iOS, and other apps by way of iOS, to reach out, request interface, information, and functionality. The container app can then project that interface, information, and functionality back to iOS or the host app right back.
For share extensions, the app you're sharing from is the host and the service you're sharing to is the container. For example, if you're in Safari or Photos, that's the host application. If you're sharing to Pinterest or Vine, that's the container. That not only provides security benefits but functional benefits as well. Neither the Pinterest nor Vine app needs to be running in advance for their share extension to work.
When a share extension is invoked it communicates securely, through iOS, back to the host app for things like posting permission or content. The developer needs to make sure all of that is available in a container that both the app and the extension have access to, but is otherwise secure in and of itself. iOS will then handle things like background video upload, leaving the extension to handle the user interaction.
Apple hasn't detailed the specifics of how all this works yet, but has said it uses similar security to the rest of iOS. Since iOS 7, Apple has done an incredible job with security and cryptography. I'm willing to bet Extensibility is enjoying something just as well thought out and just as secure.
Share extensions are just part of the the new Extensibility features offered in iOS 8 and a very specific part. They don't let you or developers do anything and everything. They're not area of effect, they're targeted. But what they do do is allow you to securely, privately share anything that interests you with anyone you want to share with, from anywhere and everywhere in iOS.
You no longer have to wait for or worry about Apple making — or not making — a specific partnership and integrating a specific service. Any service with an app on the app store can now get in on the sharing, and so can we.
Are there any social networks, instant messengers, mail apps, or photo or video sharing services you're eager to see come to Share Sheets?
More of iOS 8: Explained
- Handoff in iOS 8 and OS X Yosemite: Explained
- Making and receiving phone calls on iOS 8 for iPad and OS X Yosemite: Explained
- Sending and receiving SMS/MMS on iOS 8 for iPad and OS X Yosemite: Explained
- AirDrop and Instant Hotspot in iOS 8 and OS X Yosemite: Explained
- QuickType keyboard in iOS 8: Explained
- Interactive notifications in iOS 8: Explained
- SceneKit in iOS 8: Explained
- Metal in iOS 8: Explained
- Widgets in iOS 8: Explained
- Share extensions in iOS 8: Explained
- Action extensions in iOS 8: Explained
- Inter-app photo and video editing in iOS 8: Explained
- Custom keyboards in iOS 8: Explained
- Family Sharing on iOS 8: Explained
- iCloud Drive and Document Picker for iOS 8: Explained
- Document provider extensions in iOS 8: Explained
- TestFlight in iOS 8: Explained
- Apple Maps in iOS 8: Explained
- iMessage in iOS 8: Explained
- Photos in iOS 8: Explained
- Spotlight in iOS 8: Explained
- Health in iOS 8: Explained
- Touch ID in iOS 8: Explained
- HomeKit in iOS 8: Explained
- Adaptive UI in iOS 8: Explained
- Manual camera controls in iOS 8: Explained