1

How do you make a haptic play on the apple watch when you press a button using Objective-C and Xcode.

Dylan Murphy
  • 167
  • 1
  • 13
Leo
  • 115
  • 1
  • 10

2 Answers2

6

Objective-C:

[[WKInterfaceDevice currentDevice] playHaptic:WKHapticType.Success]

Swift:

WKInterfaceDevice.currentDevice().playHaptic(.Success)

Types of Haptic you can play:

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

Documentation: https://developer.apple.com/library/prerelease/watchos/documentation/WatchKit/Reference/WKInterfaceDevice_class/index.html#//apple_ref/occ/cl/WKInterfaceDevice

Puneet Sethi
  • 266
  • 1
  • 4
3

at least in Xcode 11 in objective-c you'd do (Xcode 11)

 [[WKInterfaceDevice currentDevice] playHaptic: WKHapticTypeSuccess];
jbiser361
  • 949
  • 7
  • 20