Search code examples
swiftwatchkitapple-watch

Bypassing playHaptic predefined cases in WatchKit


I have been working on a small project which is about vibrating the watch depending on the noise of environment, but I realised that in

WKInterfaceDevice.currentDevice().playHaptic

cases are only predefined and since that there is no API for haptic feedback I am not able to vibrate the device anything but few options. Is there another way to use haptic feedback for Apple Watch or can I bypass these predefined cases in anyway? I'm open to all suggestions I am trying to make an accessibility app and it would help to many people.

Thanks!


Solution

  • Predefined haptics

    Several haptics are predefined in Taptic Engine:

    enum WKHapticType : Int {
        case Notification
        case DirectionUp
        case DirectionDown
        case Success
        case Failure
        case Retry
        case Start
        case Stop
        case Click
    }
    

    More (Custom) Haptics?

    These are the only haptics that the Taptic engine can understand and use. No other functionality rather than these is defined for this engine.

    Also, there is no API in watchOS 2 to do so. You may wait until watchOS 3 or Apple Watch 2, which they may support custom haptics.

    NOTE: To create some custom haptics, you can always use more than one to have a blended haptic, for example Success and Failure or Notification and Click sound interesting when blended together.

    Conclusion

    1- There are 9 haptics in total and all are predefined in WKHapticType enum, which any of them is represented by an Int value.

    2- There is no API to have custom haptics in watchOS 2.

    3- Taptic engine can only perform these 9 haptics in Apple Watch 1.

    4- You can create custom haptics by joining several haptics together.