iosobjective-cvibrationiphone-vibrate

Vibrate phone when void function called


I've seen other answers on how to get the phone to vibrate, but I just can't get this thing to work. Can anyone help me?

My steps:

  1. Added the AudioToolbox framework (AudioToolbox.framework) to my target in Build Phases.
  2. #import AudioToolbox/AudioServices.h into my ViewController.h
  3. Added - (void)vibrate into my ViewController.h
  4. Added - (void)vibrate { AudioServicesPlayAlertSound(kSystemSoundID_Vibrate); } into my ViewController.h under @implementation
  5. Called [self vibrate]; in my viewDidLoad.

What am I missing here?

I don't want to use an IBAction because this isn't supposed to vibrate off a button being pushed.

Hopefully you can help, and not just share links to other Stack Overflow questions/answers that I guarantee I already checked. I will post any extra code/info necessary.

Thanks!!

I do have my phone on. It is not on silent. And it is an iPhone5. enter image description here


Solution

  • This should work. So it is likely that the vibration is disabled in your iphone sound settings.

    If you are using an iPod touch, you should also be aware that this device doesn't have a vibration motor.