-1

I was trying to implement vibration functionality on the click of UIButton with following line of code:

import AudioToolbox

AudioServicesPlayAlertSound(SystemSoundID(kSystemSoundID_Vibrate))

But nothing happens. if someone has an experience regarding this, please check the issue.

Minkle Garg
  • 723
  • 3
  • 9
  • 35

1 Answers1

1

You're probably better off using haptic feedback if the device supports it (eg iPhone).

let feedbackGenerator = UIImpactFeedbackGenerator(style: .heavy)
feedbackGenerator.impactOccurred()
rodfleischer
  • 320
  • 5
  • 9