I've been trying to make the iPhone Vibrate using this code:
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
But is not working, could it be because I am playing sound at the same time as calling this?
I've been trying to make the iPhone Vibrate using this code:
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
But is not working, could it be because I am playing sound at the same time as calling this?
If this helps anyone, I discovered that the vibrate command won't work while AVAudioRecorder
is recording. Getting round this is very simple. You just have to stop your recorder first and resume it afterwards:
[recorder stop];
AudioServicesPlaySystemSound (kSystemSoundID_Vibrate);
[recorder record];
This even works if you want to record sound and vibrate in the background using UIBackgroundModes
.
That should work fine. Has vibration been turned off on the device?
I'm using that code successfully on iPhone 4. It's not clear from the documentation of System Sound, but that code works only if the vibration is enabled in Settings.
Of course note that there are two different settings for the vibration: silent mode and normal mode. Toggling the Ring/Silent switch to Silent is not sufficient to enable vibration.
I guess you've already tried enabling the vibration in your device Settings, but worth highlighting this anyway.
On all iPhones that I've tested on (original, 3GS, and 4), it should vibrate. On the iPod touch 1st generation, it'll play a beep through the built-in speaker. On the iPod touch 2nd generation, it won't do anything. On the iPad, it won't do anything either. Those are all the devices I've tested on.