3 Jan 2016

Safari’s Surprising OS Integrations

(Disclosure: I work for Google, but not on anything related to the web platform or Chrome, and these are my personal opinions.)

I was surprised to learn that Safari integrates with the underlying OS, iOS or OS X, in many ways:

To begin with, Safari on iOS offers single-sign on with native apps: if you have the Pinterest app installed and are logged in, Safari can automatically log you in to the pinterest web site. And vice-versa.

Another form of SSO is offered by the Safari View Controller on iOS. This is a component that apps can use to provide an embedded web browser, with full access to Safari state: you are automatically logged in to sites you are logged in to in Safari. If you have to log in, usernames and passwords are autofilled. As are addresses, phone numbers and credit card information. Because it is Safari, just running within another app. Reader mode is also available to let you read an article without distraction.

Videos playing in Safari on iOS support picture-in-picture, along with embeded and full-screen. The user, or the web app, can move between these modes. AirPlay also just works — videos played by a web app can be airplayed on an Apple TV. Apps can also detect the availability of AirPlay peripherals and present a chooser to the user to pick a device to play the video on.

A web app can ask Safari to use the system font, by using font-family: apple-system. This is better than hardcoding a font name, since it changes between releases. This may seem like a detail, but getting the details right in aggregate leads to consistency, making the web app fit in on the platform.

Safari on OS X also lets web apps display notifications like native apps can. These show in Notification Center along with notifications from native apps. You can control them the same way, say by turning sound on or off.

Safari on OS X also supports Force Touch. In addition to the usual mousedown and mouseup events, web apps can receive forcetouchdown and forcetouchup events. And events for pressure changes between forcetouchdown and forcetouchup. Web apps also get an opportunity to override the default system behavior for force touch, like looking up a word in the dictionary, and instead provide their own action, like peeking into an email from the inbox.

These are the integrations Safari has today. One can imagine more integrations in the future:

Apple can extend their payment APIs to the web. Apple has two payment APIs: Apple Pay and In-app Purchase. The former is for real-world products and services, as a substitute for a credit card. The latter is for things like extra storage in Dropbox or extra features in Pro versions of apps. Apple can extend both to the web, so that you can place an order on the Amazon mobile web app, or buy more storage on Dropbox using their web app.

Apple can support Touch ID to unlock a web app, as a secure alternative to prompting the user for their password. Some services like Google periodically prompt the user to reenter their password, and when they try to perform an action that could be sensitive, like viewing credit card information on Amazon. Touch ID could substitute this.

Taking this one step further, Apple could offer a Login With iCloud option, in addition to the Login With Google and Login With Facebook options web apps have. This would eliminate the hassle of choosing and remembering yet another username and password.

Apple could also let web apps access data stored in iCloud. If I have a notes app that stores its data in iCloud, and the developer wants to offer a web app, they should be able to [2]. This will require Apple to publicly document and support a REST or JSON-RPC API, rather than just providing a framework (or library) and leaving the underlying protocol undocumented publicly.

As other examples, web apps could capture and display Live Photos, shake to undo, support 3D Touch on iOS, and interact with other devices like the Apple Watch and HomeKit devices.

Deeper platform integrations will make web apps easier to use on iOS and OS X. And web apps would provide fallbacks to Apple-only features like Touch ID, so that the web app is perfectly functional on other platforms. Web apps can work better on Apple platforms, without working worse on other platforms than do today. This is a win-win situation.

[1] Web apps will be able to access their own data without any prompts, subject to a verification that the developer of the web app is the same as that of the native app. Web apps should also be able to access files belong to other apps if the user picks a file using an Apple-supplied file picker. Apple can offer a picker as a web app, running on iCloud.com. The web app would open the Apple picker in a new tab or in an iframe or something.

No comments:

Post a Comment