WatchKit API for Force Touch / Digital Crown? WatchKit API for Force Touch / Digital Crown? ios ios

WatchKit API for Force Touch / Digital Crown?


watchOS 3 adds WKCrownSequencer and WKCrownDelegate to report the state of the digital crown (such as rotational speed), as well as to receive notifications when the user rotates the crown.

You can use the crown sequencer to provide general input to control scenes or interface objects.

Apple has updated their WatchKit Catalog sample code to include a WKInterfaceController crown sequencer example demonstrating how to use the Apple Watch digital crown to interact with other objects:

class CrownDetailController: WKInterfaceController, WKCrownDelegate {    @IBOutlet var velocityLabel: WKInterfaceLabel!    @IBOutlet var stateLabel: WKInterfaceLabel!    @IBOutlet var pickerView: WKInterfacePicker!    override func awake(withContext context: AnyObject?) {        super.awake(withContext: context)        let itemList: [(String, String)] = [            ("Item 1", "Red"),            ("Item 2", "Green"),            ("Item 3", "Blue")        ]        let pickerItems: [WKPickerItem] = itemList.map {            let pickerItem = WKPickerItem()            pickerItem.caption = $0.0            pickerItem.title = $0.1            return pickerItem        }        pickerView.setItems(pickerItems)        crownSequencer.delegate = self    }    override func willActivate() {        // This method is called when watch view controller is about to be visible to user        super.willActivate()        crownSequencer.focus()    }    @IBAction func focusCrown(sender: AnyObject) {        crownSequencer.focus()    }    func updateCrownLabels() {        velocityLabel.setText(String(format: "RPS: %2.2lf", crownSequencer.rotationsPerSecond))        stateLabel.setText(crownSequencer.isIdle ? "Idle: true" : "Idle: false")    }    func crownDidBecomeIdle(_ crownSequencer: WKCrownSequencer?) {        updateCrownLabels()    }    func crownDidRotate(_ crownSequencer: WKCrownSequencer?, rotationalDelta: Double) {        updateCrownLabels()    }}


At present (Xcode 6.2 beta 3) Apple have indicated that the Digital Crown will scroll page content up and down in third party apps, but apps cannot register to receive notifications from it or to use it as an input device. It seems highly likely that this is due to concerns about either latency leading to non-responsiveness, or battery life, given third party code is running solely in the WatchKit App Extension on the iPhone and therefore these events would have to be sent in a wireless stream back to the phone.

It is possible to use Force Touch as an input method in third party apps. At this point, I believe the only use Apple has advised for force touch in any application is to display a contextual menu, and third party developers have full access to this. You do not need to register to receive a force touch event. You simply create a menu in interface builder, add menu items to it, and then wire those menu items to IBActions in your WatchKit Extension. It is rather strange to not have to connect the menu to something equivalent to a force touch gesture recogniser, but when you try it, you'll just find it works. It may well be that this will continue to be the only access third party developers have to force touch, even after we have the ability to make native apps for the Watch later in 2015.

Apple have however encouraged developers to submit enhancement requests at http://bugreporter.apple.com so it'd be a good idea to do so, and ask for access to these APIs as a number of us already have.


At the moment there is no ability for custom event handlers for either input method. Apple employees on the Developer Forums have suggested submitting a feature request. I suspect we will get access to the Digital Crown API as soon as we can start creating native Apple Watch apps next year. At the moment it remains a significant limitation for data entry.


matomo