I want to make an app that make phone vibrate at different frequencies. How can I control the frequency of the phone vibrating?
Asked
Active
Viewed 4,663 times
6
-
Here's an answer relevant to what you're looking for. http://stackoverflow.com/questions/26455880/how-to-make-iphone-vibrate-using-swift – MVZ Nov 06 '16 at 15:28
-
I was looking for something about vibration frequency – Leo Nov 06 '16 at 15:39
-
There are no public APIs that allow custom vibration of any kind. – rmaddy Nov 06 '16 at 16:04
-
I was looking for something like this: Cycloramic for iPhone SE/5/5S http://tapsla.sh/efEZljp – Leo Nov 06 '16 at 16:16
1 Answers
1
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()
}
}
}
}

Ahmadreza
- 6,950
- 5
- 50
- 69