how to set iPhone vibrate length?

2019-05-28 12:21发布

问题:

I'm using AudioServicesPlaySystemSound to call vibrate function:

AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);

is there any way to set the duration of the vibrate? i know that the default duration is 0.4 seconds but i want sometimes to make the device vibrate less or more time then this.

回答1:

You can use these numbers for less vibration.

AudioServicesPlaySystemSound(1519); // Weak 
AudioServicesPlaySystemSound(1520); // Strong

You can merge two-three vibration for more vibration duration.



回答2:

I do not think its possible to alter that vibration duration.. Even if you achieve it using some library but I do not think Apple will be happy about that. There are chances of rejection of your App..



回答3:

You are not allowed to change the duration of vibration. If you want more you'd have to set it to start vibrating immediately after the first finishes, but Apple has been known to reject for that.