Widgets in iOS 8: Explained
Widgets are part of Extensibility, one of the biggest new features in iOS 8, and one of the most important, most enabling new technologies to come to the iPhone and iPad since the launch of the App Store. With Today view extensions, any app can present a widget that displays information and offers a small amount of interaction right in Notification Center. That makes them only ever a swipe away. So, how do widgets work?
Days of widgets past
The idea of "widgets" date back to the early days of graphical user interface (GUI) computing. The Xerox Star, Apple's Lisa and Macintosh, Microsoft's Windows, and others, were all based on the "desktop metaphor". While that included things like files and folders, notebooks and ledgers, it also included tools like calculators and calendars. The pixels may have been chunky, the colors next to nonexistent, and the internet still just a dream, but it was a beginning.
With the rise of ubiquitous online connectivity, widgets took on a new roll: dedicated, glance-able information containers. Apple introduced their vision of web-based widgets in OS X Tiger with Dashboard.
The original iPhone was supposed to include a version of OS X-style Dashboard widgets, namely Weather and Stocks. They wouldn't have looked or acted any differently than any other full-screen iPhone app, but they would have been built like Dashboard widgets, using Apple's web technologies instead of native Objective-C. Since the presentation was to be no different, and the limits of WebKit at the time meant performance wasn't as good as native apps, they were ultimately rewritten in Objective-C anyway.
Other platforms, including Nokia (pre-Windows Phone) and Android went ahead with widgets. What's more, they distinguished them from full-screen apps by making them smaller and letting them live on the home screen, amid the app icons. Power users loved them, but few mainstream customers embrace them. According to HTC, a prominent vendor of Android devices:
- Widgets aren't widely used – weather, clock and music are the most used and after that, fewer than 10% of customers use any other widgets.
- Most of you don't modify your home screens much. In fact, after the first month of use, approximately 80% of you don't change your home screens any more.
With iOS 5, Apple brought limited widgets — our old friends Weather and Stocks — to the iPhone and iPad. Instead of putting them on the home screen, however, Apple put them in the then-brand new Notification Center.
For Apple, the iOS home screen was never meant to be a destination but rather a transport. It was never meant for anyone to stop and stare at, but to quickly find and get into apps. When the App Store made apps more abundant, Apple added Spotlight as an ancillary way to help do just that.
Notification Center changed things. It could be pulled down from anywhere, including the home screen (and eventually the lock screen), and more importantly, from inside any app. Instead of having to leave what you were doing to go find information, you could pull that information to wherever you were, whenever you wanted, and then go right back to what you were doing with very little cognitive load. It wasn't perfect, but it was better.
iOS 7 split notifications and widgets apart, putting widgets in their own Today view, moving Weather to the Today Summary, and adding support for Calendar, Reminders, predictive location, and the Tomorrow Summary. Yet they were still limited to built-in apps and services.
iOS 8 and Extensibility take it even further, allowing App Store apps to offer up their own Today view widgets — helpful information status indicators, simple, interactive utilities, and ways to launch into the full app when and if needed — easily accessible from anywhere on the iPhone or iPad, informational and interactive.
How custom widgets work
If you've used Notification Center's Today view in iOS 7, you already know how custom widgets are going to work in iOS 8. You just pull down Notification Center from the lock screen (if enabled), home screen, or from within any app, and if you're not already in the Today view, you simply tap the Today tab at the top.
In iOS 8, the built-in widgets provided by Apple include Today Summary, Traffic Conditions, Calendar, Reminders, Stocks, and Tomorrow Summary.
What's new is what's at the bottom: an Edit button and a notification area that tells you how many new third-party widgets are available to you. Tap the Edit button and you can enable or disable any of the built-in widgets and reorder them any way you like. Tap the New Widget notification and you can add any new, custom widget that has become available.
New widgets become available when you install an app from the App Store. If the app includes a widget, the widget notification area will tell you about it. Tap the widget you want added, and it's added. Once added, you can order App Store widgets just like the built-in widgets, and remove them if and when you decide you no longer want or need them.
For example, if you download a sports news network app, it could include a widget that presents you with up-to-date scores of the two most recent games in any league you choose to follow, as well as a headline or two of breaking news. Or, if you download a social networking app, it could include a couple status entries, and maybe a Show More option to see even more entries. A package tracker app's widget could keep you up-to-date on all your deliveries. Breaking news, latest weather — all of those, and more, could provide glance-able widgets right in the Notification Center Today view.
Interactive widgets and limitations
Like the new notification system, the new widget system in iOS 8 is interactive. So, not only can the widgets provide you with snippets of information, they can also allow you to perform minor tasks as well.
For example, an auction widget can show you the items you've last bid on and whether or not you're currently being outbid, but also allow you to up your bid right there in the widget and retake the lead. A social widget can let you glimpse a few entries in your timeline and Like or Repost right from the widget.
What widgets can't do is invoke the keyboard, which means widgets can't take text input the way a Messages quick reply notification can. Complex actions are also beyond the scope of widgets. So, for example, you can't change which stocks are shown in the Stock widget. They simply reflect the stocks shown in the Stocks app. In order to change the widget, you have to change the app.
How developers add widgets to apps
For developers, widgets in the Today view are remote view controllers. They're best thought of as independent "child" apps all their own that present themselves and their data to Notification Center. That gives them a number of advantages, including security (see below). It also means that the container app doesn't need to be running in order for the widget to be working. Even if a the container app becomes a memory drain and gets jettisoned, someone using the widget at that very moment wouldn't even notice.
It's that type of seamless user experience Apple is stressing with widgets.
Performance is paramount. Since a typical person may have several widgets running at once, and resources are always limited, developers need to keep things simple and streamlined. Whenever someone pulls down Notification Center to access a widget, the data needs to be there, ready and waiting. That means pulling in anything big and new in the background and caching it so that it can persist in the widget for as long as it needs to.
For the interface, Notification Center defines the width and a default height, but developers can alter the height as needed. That's done by defining vertical constraints with Auto layout or by setting it manually in code. Widgets can also expand in size, either because the content itself changes, or as the result of a user action, like tapping a Show More button. Notification Center will handle the size change and, of course, animate it. Developers get to animate their content changes within it. However, Apple encourages developers not to make widgets so long that people will need to scroll to see all of them.
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
The thing about Extensibility and widgets is that Apple claims they provide extra functionality without sacrificing the excellent security model iOS was built on. This is a big part of the reason it took so long for App Store widgets to appear — Apple had to do a tremendous amount of work over the course of several years and several releases to make it all possible. Things like porting Apple's interprocess communication system, XPC, from OS X to iOS.
In iOS, apps are "sandboxed". That means they can only access their own data, not the data of any other app or the system. There are some exceptions, but those require the granting of explicit permission. For example to access contacts or photos, or to "open in" another app, a button tap is required. All of this so that, if anything malicious ever does manage to get in, it's very, very hard for it to go anywhere else or grab any data from anywhere else.
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.
So, for widgets, Notification Center is the host. The widget communicates only with Notification Center, not with its container app at all. (Which is why container apps don't have to be running, or can be jettisoned without affecting the widget.) When a widget needs information from its container app, it does so through iOS, and through privately shared data resources.
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 cryptograph. I'm willing to bet Extensibility is enjoying something just as well thought out and just as secure.
What's most impressive about Extensibility in general and widgets in specific is that Apple has set them up to work the same in both OS X and iOS. That involved a lot more work on their part — shortcuts for one system or the other couldn't be exploited — but ultimately consistency is a feature, and that discipline has resulted in a more unified, better framework for both developers and customers.
It's taken a long time for custom widgets to arrive on iOS, but there's every indication Apple has done them in the right way and put them in the right place.
Will you be using them? And if so, any particular third-party widgets you're most looking forward to?
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