Leo
Leo

Reputation: 125

How do you make a haptic play on the apple watch using Objective-C code

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

Upvotes: 2

Views: 1783

Answers (2)

jbiser361
jbiser361

Reputation: 987

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

 [[WKInterfaceDevice currentDevice] playHaptic: WKHapticTypeSuccess];

Upvotes: 3

Puneet Sethi
Puneet Sethi

Reputation: 276

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

Upvotes: 7

Related Questions