Dmitry
Dmitry

Reputation: 41

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

Upvotes: 1

Views: 107

Answers (1)

Vikas Saini
Vikas Saini

Reputation: 591

  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()

Upvotes: 2

Related Questions