Search code examples
watchkitapple-watchwatchos-2taptic-engine

Where to find Taptic feedback API documentation or capabilities for watchOS 2?


I'm interested in building an app for watchOS 2 using haptic feedback. Currently I do not have the Apple Watch, but I have access to the Apple Developer Program. I've tried looking at the watchOS Developer Library and watchOS 2 Release Notes.

I do not see any mention of how to access the Taptic engine programmatically or what it is capable of in the current watchOS 2.

How can I access the Taptic engine programmatically or understand what the new Taptic API is capable of doing?


Solution

  • You can find the Apple API documentations for the haptic feedback here:

    https://developer.apple.com/documentation/watchkit/wkinterfacedevice

    You will find a function named

    - playHaptic:
    

    So you need to call this function to play the related haptic. This can be done with the following code:

    Swift:

    WKInterfaceDevice.currentDevice().playHaptic(<#WKHapticType#>)
    

    Objective-C:

    [[WKInterfaceDevice currentDevice] playHaptic:<#WKHapticType#>]
    

    Be aware though, for now these feedbacks are unavailable to test on the simulator (because these haptic feedbacks are produced by the new Taptic Engine which is not accessible from any other device than a real Apple Watch), but you can test it on a real device (with watchOS 2 beta installed) if you have one.

    These are the types of haptic you can play:

       WKHapticType.Notification,
       WKHapticType.DirectionUp,
       WKHapticType.DirectionDown,
       WKHapticType.Success,
       WKHapticType.Failure,
       WKHapticType.Retry,
       WKHapticType.Start,
       WKHapticType.Stop,
       WKHapticType.Click