Search code examples
iosobjective-cxcode7audiotoolbox

AudioServicesPlaySystemSound(kSystemSoundID_Vibrate)


I'm working on a Custom Alarm App and want to use Vibration in my App as soon as the alarm plays and I have used AudioToolbox and used this below code:

AudioServicesPlayAlertSound(SystemSoundID(kSystemSoundID_Vibrate))

and it worked but i want to run continuously vibration in my App.

is there any possible way to implement this??


Solution

  • You will have to repeat your vibration request.

    NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval: 1.0 target: self selector:@selector(repeat:) userInfo: nil repeats:NO];

    -(void)repeat:(id)sender{
    
      AudioServicesPlayAlertSound(SystemSoundID(kSystemSoundID_Vibrate))
    
    }