The Dock

Episode #254 | 14 minutes | published on February 4, 2017 | Uses watchOS-3
Subscribers Only
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:, 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

blog comments powered by Disqus