swalkner
swalkner

Reputation: 17359

Apple Watch: WKInterfaceDevice.current().play(.success) not working

I try to let the  Watch vibrate from within my code:

WKInterfaceDevice.current().play(.success)

but nothing happens. I also tried to ensure to be on the main thread:

DispatchQueue.main.async {
    WKInterfaceDevice.current().play(.success)
}

still nothing. Am I missing something here? I expected it to be an easy task, but I fail completely...

Upvotes: 1

Views: 1394

Answers (3)

invisible squirrel
invisible squirrel

Reputation: 3008

Check Haptic Alerts are on in device settings!

Settings -> Sounds and Haptics

enter image description here

Upvotes: 0

Sid
Sid

Reputation: 1073

Alternatively, instead of HKWorkoutSession you could use WKExtendedRuntimeSession to support running the app in the background so sounds and haptics work. This needs to be done using either the Physical therapy or Smart alarm session type.

Upvotes: 0

Zimes
Zimes

Reputation: 623

Maybe your watch app is not in the active state? Citing the official documentation:

This method has no effect when called while your shared WKExtension object's applicationState property is either background or inactive. By default, you cannot play haptic feedback in the background. The only exception are apps with an active workout session.

So, unless you have a running HKWorkoutSession, if your app is in background you're not allowed to play haptic.

Upvotes: 1

Related Questions