Vibrate one time Taptic

How to make iPhone soft vibrate one time?
Below code vibrates twice.
Is there any way to check how many times vibrate occur in simulator? 🙂

let generator = UINotificationFeedbackGenerator()
generator.notificationOccurred(.success) // .error .warning

>Solution :

  1. You can’t test vibration on a simulator, Need to use a real device for checking vibrations.

  2. for soft vibration, you can use UISelectionFeedbackGenerator and can also use UIImpactFeedbackGenerator with soft style like this:

// UISelectionFeedbackGenerator

let generator = UISelectionFeedbackGenerator()
    generator.selectionChanged()

// UIImpactFeedbackGenerator

let feedbackGenerator = UIImpactFeedbackGenerator(style: .soft)
 feedbackGenerator.impactOccurred()

Leave a Reply