Post

Replies

Boosts

Views

Activity

how to make sound appear with haptic feedback on apple watch
I've made the code in xcode for apple watch with 2 swift view (contentView.swift and interfaceController.swift).The swift for sound and haptic feedback is in InterfaceController.swift. But the the sound does not appear with haptic feedback in apple watch after complete the xcode. the app is done but no sound appear with haptic feedback when rotate apple watch digital crown. when crown rotated but sound appear code import WatchKit import AVFoundation import WatchKit class InterfaceController: WKInterfaceController { // ... your UI elements func playSelectionHapticAndSound() { // Play a haptic feedback pattern WKInterfaceDevice.current().play(.success) // Load and play a selection sound effect guard let soundURL = Bundle.main.url(forResource: "spin", withExtension: "wav") else { return } do { let player = try AVAudioPlayer(contentsOf: soundURL) player.play() } catch { print("Error playing sound: \(error)") } } }
1
0
297
1w