Jump to content

Action extensions in iOS 8: Explained


Recommended Posts

Guest Rene Ritchie
Posted

01f25903f44b4ad9a839a78a50983118.jpg.ad9f3838a71a8dc36988f8c53d44a9c1.jpg

 

Share Sheets in iOS have another name behind the scenes — activity view controllers. That's fitting because, in addition to providing sharing options, they also provide for other "activities", like action options. Traditionally, that's been system options such as copy, save, print, etc. However, just like custom sharing options have now been made available in iOS 8, so too have custom action options. They're part of the new Extensibility feature set, one of the most important additions to iOS since the advent of the App Store. Extensibility enables Widgets, custom keyboards, and so much more, including custom action extensions. So, how do action extensions work?

 

Action packed

 

 

81322f53e42d8f3a8ba1384d0629e0fc.jpg.c0e03a804dcb14993f908b36bc603157.jpg

 

Action options first came to iOS as part of the same drab lists that contained share options. Not only did that fail to provide a lot of visual distinction, it didn't scale.

 

When share options moved to the grid-like Share Sheets in iOS 6, actions joined them. There, share options got the full color icons of the apps with which they were associated, and action options got custom, grayscale icons that indicated their function — save to Camera Roll, print to AirPrint, copy to clipboard, etc. Share and action options still ran together, however, and the grid scaled only slightly better than the list.

 

With iOS 7, Share Sheets got a new look and feel to match Apple's new design language, and actions switched from being grayscale to black and white. Moreover, actions got their own distinct row along with horizontal scrolling to fit in as many as needed. However, there were still only a very few action options, and only the ones that matched services Apple provided.

 

iOS 8 changes that.

 

How action extensions work

 

 

9bae29fb0d624183766f3d09379cf573.jpg.850dc710aaeb3f46e0e8f8066c4e1a67.jpg

 

Extensibility in iOS 8 means that we're not longer bound to action options supported by Apple and Apple alone. We no longer have to wait for things like AirPlay and AirPrint to be rolled out, or wonder if Apple will ever add system-wide support for someone else's product or service. Now any app can add an action extension that increases the utility and diversity of other apps and iOS itself.

 

So, instead of Apple and Microsoft making a deal to get Bing translate built into Safari, Microsoft can simple make an action extension to the Bing app and, thanks to Extensibility, it'll be available just like the built in options.

 

Getting to an action extension is simple. If you're in Safari and you're reading iMore, and your native language isn't English but French, you can tap the Share button, scroll horizontally to the Bing Translate extension, and voila, the page would translate-in-place for you.

 

To help keep things manageable, action extensions tell iOS their context — whether they work on text or images, form fields or something else — and iOS will only present that work in that context. So, if you select text, you won't get image action options.

 

You can also arrange action extensions in any order you like. Scroll to the end of the action options on the Share Sheet, tap the More button, and slide any item in the list up or down. Unlike custom share options, however, you can't toggle any of the default system actions off, but you can toggle the custom ones

 

Still, that means if you use the 1Password action extension to autofill your passwords all the time, you can put it into one of the first few slots. Then it's always immediately available, no scrolling required, whenever you tap the Share button.

 

Like plugins, action extensions don't just add more apps, they add more functionality to the system and existing apps. Say goodbye to having to leave Safari, go to 1Password, use the in-app browser, or copy the password to the clipboard and find your way back to Safari. With iOS 8, Extensibility, and action extensions, everything just works, right where you need it, right when you need it.

 

Custom Safari actions

 

 

94cb05ceb543f84f3c4e59d775d28ad3.jpg.486bf7e4e95dd24801262535b1b78d1e.jpg

 

There's also a special kind of action extension in iOS specifically for Safari. They're called custom Safari actions and they come in two types:

 

  • Action extensions that present it's own interface
  • Action extensions that presents no interface.

 

An example of an action extension that presents its own interface would be 1Password, which could ask you which of your 3 different Google accounts you want to use to login to YouTube.com.

 

An example of an action extension that currently doesn't present an interface would be Bing Translate, which, as demoed at WWDC, instantly replaces the existing text on a webpage with translated text.

 

Developing action extensions

 

 

6d0b2d89194360bb4a1ffa7818e5c833.jpg.02ae650b5bba0b331a613edf85385a87.jpg

 

Activity extensions let developers wrap up a piece of functionality from their app and make it available to iOS and other apps via the built-in Share Sheets.

 

Although extensions are primarily view controller based on iOS, as mentioned above, activity extensions can be view controller based, or for custom Safari extensions, they can have no view.

 

The difference between standard action extensions and custom Safari extensions is that only custom Safari extensions can use JavaScript integration. They get full access to the Document Object Model (DOM) and that means they can, for example, grab an image from a web page, mark it up, and then put the updated version back in place of the original.

 

Like with share extensions, activity extensions have activation rules to tell the system what kinds of data they can manipulate. That way, for example, if a paragraph is selected, only custom actions that can manipulate text are displayed among the options. If a picture is selected, only custom actions that can manipulate images are displayed.

 

Apple has several resources to help developers with action extensions:

 

Action extensions and security

 

 

fd20d38292ba098455150dd7938b27b6.jpg.afea77173d272ecdc8f8729fff1c6610.jpg

 

iOS is a security- and privacy-first operating system. Adding functionality like action extensions is one thing. Adding them while maintaining a high level of security is quite another. With 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 action 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, that the host application. If you're using an action like filling a password from 1Password or translating text from Bing, those would be the containers. Beyond security, that provides reliability — neither 1Password nor Bing in those examples would have to be running in advance, or persisting in the background, for the action extensions to be invoked.

 

When an action extension is called, it communicates securely through iOS to its host app for things like the authentication and password information or the translation libraries. That's then sent back to the container app so the action can complete.

 

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.

 

Bottom line

 

 

Activity extensions provide incredible new functionality to iOS 8 and to iOS 8 apps. It's important to remember that this is Extensibility 1.0, and just like multitasking has, Extensibility will no doubt evolve over time. For example, it looks like 1Password can currently only fill passwords in Safari, not in web views or native interfaces in other apps.

 

Regardless, activity extensions mean iPhone and iPad owners will get to spend less time jumping between apps and more time getting things done within the apps they're already using. And that's a huge win.

 

Any apps you're especially interested in getting action extensions for come iOS 8 launch?

 

1e812abcc4c2fc998cf9083fe99e38ba.gif.c7da3ffb30561f135b94e1bd487aaa6c.gif

 

 

4ab3466b8c9d5ad78d366d33cd88a7e0._.png.d7068cd6ca6ba75ffe0f374c9cefc122.png

8a64d77b8783967cded3d80c5fa70c2f._.png.a957e957d44b969cf27cec3a278893c1.png

f25061641540a1fd2a21171c6314a15d._.png.205924581d797b8caf48ab84c509b6e1.png

 

5a2737ee337eda5969b3375ec1903fe3._.gif.f7e7f400e6db7f9ac7f8687e073c5b82.gif00fd629571e1eaa1b807fff6bc4149cf._.gif.9880e64b835d3d725997ad64d9444f8b.gifdce33ad3843164089da6ff94a39d8320._.gif.cd8b6effd4bee5c006df643690eed4fa.gif

 

Continue reading...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...