Acerbic Resonance

There’s no substitute for a good subtitle.

How To Make iPhone Vibrate For A Long Time?

I recently began developing a new iPhone application for work that will be used to treat various acupuncture points using sound, vibration and pressure.  Sound and pressure are no-brainers, as sound is easily used via the exposed libraries in the iPhone SDK, but vibration is turning out to not be so easy.

Apple has only provided a single API for interacting with the vibrate feature of their iPhone OS devices.  It looks like this:


That’s it.

The astute among you may notice that there is no way to adjust things like the duration of the vibration, the frequency or amplitude (i.e., a fast or slow buzz, a”heavy” or “light” buzz, etc).  In fact, the above API call will produce exactly 0.4 seconds of vibration and 0.1 seconds of silence.

In order to have a decent effect on an acupuncture point, the point needs to be massaged or vibrated for, say, 30 seconds at a time, so I set out to find a way to make it vibrate continuously for 30 seconds.  After asking around on IRC and google, all I heard was “you can’t do that, so stop trying.”  Unsatisfied with this, I came up with the idea of calling the vibrate function repeatedly such that each subsequent call fires just before the prior one enters it’s 0.1 seconds of silence.  To do this, I hacked up the following:

for (int i = 1; i < 60; i++)
[self performSelector:@selector(vibe:) withObject:self afterDelay:i *.3f];

And the selector that it performs:


(note that in the above code I was not going for precisely 30 seconds – just a continuous buzz to see if it could be done.)

The first time I ran this, it actually worked.  I was shocked. However, the above is a pretty nasty hack, kludge, and abuse of the API that Apple provides, and I’m pretty sure that if I tried to get an app approved with something like the above they’d smack me around some.

So, while it appears that you can beat up on the API enough to make the device vibrate continuously, I don’t recommend that you do.

Update:  I was recently asked if I could provide a demo XCode project that incorporated the above code snippets.  Here it is:

Buzz Buzz Demo

Another update:  Apple has removed this API call, and replaced it with:



9 responses to “How To Make iPhone Vibrate For A Long Time?”

  1. Racing Ferret Avatar
    Racing Ferret

    I’m sure that would be allowed in the store by Apple, some of my dirty rotten hacks are much worse than that 🙂

    1. Yup, I’m sure you are correct that Apple would reject a continuous buzzing app – note how I mentioned this at the end of my article. Our final version of the acupuncture app that was to use this wound up using the intermittent buzz that Apple provides and supports.

  2. Nice tutorial. But It is not permitted to use continuous vibration in our applications(iPhone/iPad). I read this in the below article:

  3. I have tried your solution. The thing is there is still a 0.1 gap between the first vibration and the following continuous one. Did you manage to solve this problem?

    1. Back when I wrote this article (several years ago) yes – I was able to get a continuous vibration using the code I posted. It is entirely possible that Apple has since changed the internal behavior of their APIs. Have you tried messing with the timing?

  4. Yes. No matter how I change the timing, the problem remains. I also tried to silence the very first vibration but it doesn’t help. It is alway the first vibration in effect that brings this small gap with the following continuous ones.

    1. Apple must have changed the underlying APIs since I wrote that up.

      1. it seems to be. Thanks for the tutorial and help.

  5. Hi, is there a link to the API for the intermittent buzz that Apple supports? In my searches, I can only find it linked to device complications rather than how to implement it in an application.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.