kelin
kelin

Reputation: 11994

Watch Kit: is it possible to vibrate watch programmatically?

Is it possible to vibrate watch while Watch Extension is running? We can do it on iOS in this way (force iPhone to vibrate):

AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);

I hope there is something similar on WatchKit.

Update: I have added issue to Apple radar and recieved the answer:

Engineering has determined that your bug report (20019274) is a duplicate of another issue (19025053) and will be closed.

19025053 is still open.

Update 2: AudioServicesPlayAlertSound() not working on watch simulator with any sound ID. Seems like function is not supported.

Upvotes: 24

Views: 7715

Answers (4)

Ste Prescott
Ste Prescott

Reputation: 1817

You can now ask the Watch to vibrate if you target watchOS 2.0

To do this all you need to do is call playHaptic on a WKInterfaceDevice instance with any WKHapticType. In the example below it will play the notification haptic.

Swift 3

WKInterfaceDevice.current().play(.notification)

Objective-C

[[WKInterfaceDevice currentDevice] playHaptic:WKHapticTypeNotification];

You can further read the Apple WKInterfaceDevice Documentation

Upvotes: 39

4GetFullOf
4GetFullOf

Reputation: 1738

This is the answer in objective-c after watchOS 2

[[WKInterfaceDevice currentDevice] playHaptic:WKHapticTypeNotification];

Upvotes: 2

John
John

Reputation: 1

With WatchKit, you have to remember that your code runs on the iPhone and not on the watch. Therefore, AudioServicesPlaySystemSound call from a WatchKit extension would run on the iPhone, not on the watch. It will make the iPhone vibrate.

Upvotes: -3

cnoon
cnoon

Reputation: 16663

That's a great question, but unfortunately the answer is no. WatchKit doesn't have any APIs available to control haptic feedback. If you would really like to see this feature supported, I'd suggest you file a radar as a feature request.

Upvotes: 5

Related Questions