Guides and Sample Code

Developer

App Programming Guide for watchOS

On This Page

Developing for Apple Watch

With Apple Watch, users can now access information in a way that is both distinctly personal and unobtrusive. With just a raise of the wrist, users can receive and respond to notifications, see essential information in a complication, and much more. Developing for Apple Watch means providing your users with important, helpful, and impactful information in the most immediate, convenient way (Figure 1-1).

Figure 1-1The Apple Watch with complications image: ../Art/watchHeroImage_2x.png

The projects you create for Apple Watch consist of two separate bundles: a Watch app and a WatchKit extension. The Watch app bundle contains the storyboards and resource files associated with all of your app’s user interfaces. The WatchKit extension bundle contains the extension delegate and the controllers for managing those interfaces and for responding to user interactions. While these bundles are distributed inside an iOS app, they are then installed on the user’s Apple Watch and run locally on the watch.

A watchOS project must include a Watch app, but may also include custom notifications and complications. Don’t think of these elements as separate applications. Instead, think of them as different interfaces on the same application. Each of these interfaces provides a unique way for users to interact with your app, often letting you convey important information to the user more quickly than the app’s main interface could.

Although optional, these interfaces should not be considered secondary. In fact, the notifications and complications may be the primary interface for many users.

Notifications, and complications are not separate executables. Instead, the interface for custom notifications are included in your Watch app’s storyboard. The code for managing both notifications and complications are part of your WatchKit extension.

The Watch App

The Watch app is the actual app that the user launches from the Apple Watch Home screen. The Watch app presents your app’s full user interface. The app supports one or more screens of custom content that you define. Use the Watch app to present all of the content you support on Apple Watch, which is often only a subset of the content you support in your iOS app.

To create a Watch app, see UI Essentials.

Complications

Complications are small visual elements that appear directly on the watch face and convey important information to the user. Complications are automatically visible whenever the user looks at Apple Watch to check the time. Most watch faces support at least two or three complications, and the user can customize which complications are displayed.

Whenever your app has a complication on the active watch screen:

  • Your app has the opportunity to provide vital pieces of information to the user whenever they glance at the watch face.

  • If your app is not already running, it is launched in the background and suspended. The system keeps the suspended app in memory. This lets the system rapidly wake your app when the user taps on the complication.

  • Your app is given a larger budget for background tasks. See Background Tasks.

We recommend that all apps implement a complication, even if it only acts as an app launcher. For information about complications and how to implement them, see Complication Essentials.

Snapshots and the Dock

Apple Watch periodically takes a snapshot of your app’s interface. You can update both the currently presented interface controller and the controller’s content before the snapshot is taken. The system uses snapshots in two ways:

  • The snapshot represents your app in the dock.

  • The snapshot is used as your app’s launch image.

The dock provides a quick way for users to view or launch your app. Tapping the side button displays the dock. As users scroll through the dock, they see snapshots of their apps. If they let the dock settle for a moment, the app wakes and the snapshot is replaced by the running app.

Users can place up to ten apps in the dock. When your app is placed in the dock:

  • The user can quickly view and launch your app.

  • If your app is not already running, it is launched in the background and suspended. The system keeps the suspended app in memory. This lets the system rapidly wake your app when the user settles on or selects the app in the dock.

  • Your app is given a budget for background tasks. See Background Tasks.

For more information about snapshots, see Snapshots inWKExtensionDelegate Protocol Reference.

Background Tasks

Background tasks give your app time to run in the background, helping to ensure that the information the user wants is available before they even open your app. watchOS provides four different types of background tasks:

  • Background App Refresh Tasks. Use this task to update your app’s state in the background. Your app must schedule background app refresh tasks.

  • Background Snapshot Refresh Tasks. Use this task to update your app’s user interface. The system automatically takes a snapshot of your user interface as soon as this task completes. Your app can schedule a background snapshot refresh task; however, the system also schedules background snapshot refresh tasks to periodically update your snapshot.

  • Background Watch Connectivity Tasks. This task is triggered when your app receives background data from the paired iPhone. Use this task to receive the data. Background watch connectivity tasks are only scheduled by the system.

  • Background NSURLSession Tasks. This task is triggered when a background transfer requires authorization, or when a background transfer completes (successfully or unsuccessfully). Background NSURLSession Tasks are only scheduled by the system.

Use background tasks to ensure all your app’s interfaces (the Watch app, its complications, and any notifications that the user might see) all present a consistent and up-to-date view of your app’s data. For more information on background tasks, see Background Refresh Tasks in WKExtensionDelegate Protocol Reference.

Custom and Actionable Notifications

Apple Watch works with its paired iPhone to display notifications. Initially, Apple Watch uses a minimal interface—called a short look—to display incoming notifications. If the user’s wrist remains raised, the minimal interface changes to a more detailed interface—called a long look—displaying the contents of the notification. You can customize the long look, adding custom graphics or arranging the notification data differently from the default interface provided by the system.

watchOS 3 makes the following changes to notifications on Apple Watch:

  • Notifications use the User Notifications framework. For more information, see User Notifications Framework Reference.

  • Local notifications are delivered to the device where it was scheduled. If you schedule a local notification on Apple Watch, it is delivered to Apple Watch. If you schedule it on iPhone, it is delivered to the phone.

  • When your app receives a notification, the system launches it in the background. This lets the user quickly open your app from the notification.

  • You can use SpriteKit, SceneKit, and inline videos to produce visually rich notifications.

Apple Watch also provides automatic support for actionable notifications. Actionable notifications let you add buttons or text input to your notification interface, so that users can respond directly to the notification. For example, a notification for a meeting invitation might include buttons to accept or reject the invitation.

When your iOS app registers support for actionable notifications, Apple Watch automatically adds buttons for notification actions to the notification interfaces on Apple Watch. You just need to implement and assign a UNUserNotificationCenterDelegate object to handle the actions.

To create custom notification interfaces and actionable notifications, see Notification Essentials. For more information on registering actionable notifications, see Registering Your Actionable Notification Types in Local and Remote Notification Programming Guide.

The Glance Interface

As the name implies, a glance is meant to be looked at quickly. With a swipe from the bottom of the watch face, a glance displays only your app’s most important information. Glances are nonscrolling; the entire glance interface must fit on a single screen, and the information in a glance is read-only, so glances do not contain buttons, switches, or other interactive controls. Tapping a glance launches your Watch app’s main interface.

To create a glance interface for your watchOS 2 app, see Glance Essentials.

Designing Your User Interface

The personal nature of Apple Watch requires a different approach when it comes to designing Watch app, notification, and complication interfaces. Your interfaces need to display information quickly and facilitate fast navigation and interactions. Creating that kind of interface means you should not simply port your existing iOS app behavior over to Apple Watch. Instead, create a complementary experience to your iOS app.

Additionally, the Watch app, notifications, and complications each have their own unique role. Complications provide immediate access to information directly on the watch face; however, they are limited in both the amount and type of information they can present. Notifications are presented to the user as an alert, giving them a way to take a specific yet quick action. Finally, the Watch app can provide a richer experience with an opportunity for further interaction and input by the user, but should still be designed for quick, streamlined interactions.

For guidance on designing interfaces for Apple Watch, see Apple Watch Human Interface Guidelines. In particular, the App Components section describes the differences between the Watch app, notifications, and complications.