Episode #254

The Dock

Series: Up to Speed with watchOS

14 minutes
Published on February 4, 2017

This video is only available to subscribers. Get access to this video and 578 others.

In this episode Conrad takes us through supporting the new dock feature in watchOS 3. If you want your watch app to be used, you should ensure it plays well with the dock by providing relevant UI snapshots that create a more seamless experience. The reward is that your app is treated like a first class citizen and kept running for longer!

Episode Links

Handling a Snapshot Request

func handle(_ backgroundTasks: Set<WKRefreshBackgroundTask>) {
    for task in backgroundTasks {
        if let snapshotTask = task as? WKSnapshotRefreshBackgroundTask {
        } else {

func handleSnapshotTask(_ snapshotTask : WKSnapshotRefreshBackgroundTask) {
    if let order = Order.currentOrder() {
        updateSnapshot(status: .Ordered(order, snapshot: true))
        snapshotTask.setTaskCompleted(restoredDefaultState: false, estimatedSnapshotExpiration: order.date, userInfo: nil)
    } else {
        updateSnapshot(status: .None)
        snapshotTask.setTaskCompleted(restoredDefaultState: true, estimatedSnapshotExpiration: Date.distantFuture, userInfo: nil)

Scheduling a Snapshot Request

let date = currentOrder.deliveryDate

WKExtension.shared().scheduleSnapshotRefresh(withPreferredDate: date, userInfo: nil, scheduledCompletion: { error in


This episode uses Watchos 3.