1

I am using the following source code for the iPhone vibrating.But Its not working in iPhone 6s device. Could any one guide me for do this task in ios swift

extension UIDevice {
        static func vibrate() {
            AudioServicesPlaySystemSound(kSystemSoundID_Vibrate)
        }
    }

@objc func sos_Tapped(sender: UIButton!) {                        
        UIDevice.vibrate()
}
Ashley Mills
  • 50,474
  • 16
  • 129
  • 160

2 Answers2

0

use this code

AudioServicesPlaySystemSound(SystemSoundID(kSystemSoundID_Vibrate))
  • 2
    While this code may answer the question, providing additional context regarding how and/or why it solves the problem would improve the answer's long-term value. – Tiago Martins Peres Oct 22 '18 at 12:49
0

Since you have mentioned iPhone 6s. You should really consider using UIFeedbackGenerator to achieve this.

Eric Aya
  • 69,473
  • 35
  • 181
  • 253
iOSer
  • 2,241
  • 1
  • 18
  • 26