Vibrate for a long time?

2019-07-04 05:21发布

问题:

I want to make an app where while the user is pushing down a button the phone vibrates until the user releases the button.

Ive searched around and I haven't found a way to make it a long vibrate, except for a very old tutorial from 2009 which seems to be outdated.

回答1:

It's not allowed by Apple to use the vibration as you want to:

Vibration. It is not permitted to use continuous vibration in your apps – short bursts as warnings is all that is allowed. Don’t bother trying to set up a timer to keep the vibration going, it will cause your app to be rejected.

It's not the method, but the result, that's not permitted.

Source: http://10base-t.com/unofficial-appstore-rejection-criteria/



回答2:

Look on these options,

1) AudioServicesPlayAlertSound(kSystemSoundID_Vibrate);
2) AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);

also
Making the iPhone vibrate

And, you need to import AudioToolBox framework,

 #import <AudioToolbox/AudioServices.h>


回答3:

AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);

repeat this line in between you start-stop vibrate. don't forgot to add and import

#import <AudioToolbox/AudioToolbox.h> 

framework to your project.