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 Source Code The Dock Apple Watch Human Interface Guidelines Extension Delegate Documentation Handling a Snapshot Request func handle(_ backgroundTasks: Set<WKRefreshBackgroundTask>) { for task in backgroundTasks { if let snapshotTask = task as? WKSnapshotRefreshBackgroundTask { handleSnapshotTask(snapshotTask) } else { handleRefreshTask(task) } } } 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 })