I have been working with Apple Watch OS 2 for a while, but have not succeeded in triggering vibration on Apple Watch standalone app in Swift, using Xcode Version 7.0 beta 6 (7A192o).
All tutorials using vibration on iPhone in Swift look like:
import AudioToolbox
...
AudioServicesPlayAlertSound(SystemSoundID(kSystemSoundID_Vibrate))
But I cannot import the AudioToolbox
library.
I get the error:
Could not build Objective-C module "AudioToolbox"
Has anyone already found the way to do it?
Open the Settings app. Scroll down and tap Sounds & Haptics. Turn Haptic Alerts on or off. To add extra emphasis to haptic alerts, tap Prominent.
On your iPhone, in the Watch app, go to: My Watch > Sounds & Haptics: Check that the Alert Volume is towards the centre or right hand side. Check that Silent Mode is not enabled. Check that Haptic Strength is set to the middle or far right hand side of the slider.
Check Haptic Settings for Other Apps If your Apple Watch fails to vibrate for any other app-related alerts (e.g., when you receive a VIP message from Mail), open the Watch app on your iPhone, locate and tap the app, and make sure that any Haptic notifications are active.
You can generate haptic & auditory feedback, using:
WKInterfaceDevice.currentDevice().playHaptic(.Click)
'Click' is one of the 'cases' (types of vibration/beeps) that you can choose, cfr:
enum WKHapticType : Int {
case Notification
case DirectionUp
case DirectionDown
case Success
case Failure
case Retry
case Start
case Stop
case Click
}
This only works on the device, not in the simulator.
In Swift 3:
WKInterfaceDevice.current().play(.success)
I'm not a expert in WatchKit but I know that with Watch OS 2 you can use:
WKInterfaceDevice().playHaptic(.Notification)
The function playHaptic
called on a WKInterfaceDevice
instance engage the haptic engine in Apple Watch.
See more in the Apple documentation.
The Correct format is
WKInterfaceDevice.currentDevice().playHaptic(.Notification)
You can easily play the notification sound on watch
Function :
WKInterfaceDevice().playHaptic(.Notification)
Here you have : Documentation
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With