Call and control vibration using Swift and iOS8

How can I cause vibration with Swift and control its duration? Can you also define other parameters? I would like to cause a very short vibration with Swift.

I tried the following function:

func () { AudioServicesPlaySystemSound(kSystemSoundID_Vibrate) } 

but I get this error:

 'Int' is not convertible to 'SystemSoundID' 
+5
source share
2 answers

I have the same problem, but 1352 works for me instead of kSystemSoundID_Vibrate .

  AudioServicesPlaySystemSound(1352) 

The above solution was used as a temporary workaround. As many others have noted, it is better to use AudioServicesPlayAlertSound(SystemSoundID(kSystemSoundID_Vibrate)) , since the solution above is not subject to proof.

-4
source

This would be a better solution:

AudioServicesPlayAlertSound(SystemSoundID(kSystemSoundID_Vibrate))

+26
source

Source: https://habr.com/ru/post/1201665/


All Articles