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
CodePudding user response:
You can't test vibration on a simulator, Need to use a real device for checking vibrations.
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()