Make iPhone vibrate: AudioServicesPlaySystemSound(kSystemSoundID_Vibrate) undeclared

17,740

Try:

AudioServicesPlayAlertSound(kSystemSoundID_Vibrate);

EDIT: Also make sure you import AudioToolbox.framework

  • #import <AudioToolbox/AudioToolbox.h>
Share:
17,740
Ben Lu
Author by

Ben Lu

Updated on June 26, 2022

Comments

  • Ben Lu
    Ben Lu almost 2 years

    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?

  • Ben Lu
    Ben Lu almost 12 years
    Same error and there's no AudioServicesPlayAlertSound() method. Is it right to add AudioToolBox.framework?
  • Babul
    Babul over 11 years
    Hi, can we make the iPhone Vibrate 2 times with the above one ? @skram
  • user2899094
    user2899094 almost 4 years
    how do you set the duration of the vibration using this method?