Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 236
Alex Stone Avatar asked Jul 08 '15 17:07

Alex Stone


1 Answers

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 
like image 91
Philip Avatar answered Sep 21 '22 13:09

Philip