Make iPhone vibrate: AudioServicesPlaySystemSound(kSystemSoundID_Vibrate) undeclared

Ben Lu picture Ben Lu · Jun 10, 2012 · Viewed 17.6k times · Source

I want to make iPhone vibrate and I found the code

AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);

but Xcode 4.3.2 reports error: undeclared identifier kSystemSoundID_Vibrate

What's the problem?

Answer

skram picture skram · Jun 10, 2012

Try:

AudioServicesPlayAlertSound(kSystemSoundID_Vibrate);

EDIT: Also make sure you import AudioToolbox.framework

  • #import <AudioToolbox/AudioToolbox.h>