3

I have stuck in a problem that in my alarm application for that i m creating a local notification and in my app there is a vibration on/off button when user on the vibration at that time only iPhone should vibrate sound will not come and when user off the vibration at that time only iPhone sound should come not vibrate. Please help me to solve this problem.

2 Answers2

2

Try this code.


if(isVibrationButtonOn)
{
   AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
}

Dont forget to import

AudioToolbox/AudioToolbox.h

Edit: In case of Local notification and vibration, You can refer the following discussions.

SO POST 1

SO POST 2

Community
  • 1
  • 1
Adarsh V C
  • 2,314
  • 1
  • 20
  • 37
1

You can use use these two:

AudioServicesPlayAlertSound(kSystemSoundID_Vibrate);
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);

Also add AudioToolbox.framework and import it.

Curtis
  • 101,612
  • 66
  • 270
  • 352
Abha
  • 1,032
  • 1
  • 13
  • 36