I want to make an app that make phone vibrate at different frequencies. How can I control the frequency of the phone vibrating?
I don't know if it helps, but in my case I wanted to have longer vibration for some reasons & I created this extension for it.
extension UIViewController {
func vibrate(_ style: UIImpactFeedbackGenerator.FeedbackStyle = .heavy) {
let impactFeedbackgenerator = UIImpactFeedbackGenerator(style: style)
impactFeedbackgenerator.prepare()
impactFeedbackgenerator.impactOccurred()
}
func vibrateBomb() {
for i in 0...4 {
DispatchQueue.main.asyncAfter(deadline: .now() + Double(i * 1)/3) {
self.vibrate()
}
DispatchQueue.main.asyncAfter(deadline: .now() + Double(i * 1)/5) {
self.vibrate()
}
DispatchQueue.main.asyncAfter(deadline: .now() + Double(i * 1)/8) {
self.vibrate()
}
}
}
}
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