tags:

views:

4925

answers:

4

In the iPhone 2.x firmware, can you make the iPhone vibrate for durations other than the system-defined:

AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);

In jailbroken phones, you used to be able to use the MeCCA.framework to do this:

http://pastie.org/94481

MeCCA_Vibrator *v = new MeCCA_Vibrator;
v->activate(1);
sleep(5);
v->deactivate();

But MeCCA.framework doesn't exist on my 2.x iPhone.

Thanks.

+3  A: 

There's no way to do this using the SDK, sorry.

Ben Gottlieb
+1  A: 

Not only is this impossible to do using the SDK, but it's also the first item in the Unofficial App Store Rejection Criteria.

Can Berk Güder
+4  A: 

Yes, this is something that has caused AppStore rejections in the past, and probably will again...which means it is still possible to do it.

Answering my own question, here's how to do it:

extern void * _CTServerConnectionCreate(CFAllocatorRef, int (*)(void *, CFStringRef, CFDictionaryRef, void *), int *);
extern int _CTServerConnectionSetVibratorState(int *, void *, int, int, float, float, float);

initialize:

connection = _CTServerConnectionCreate(kCFAllocatorDefault, &vibratecallback, &x);

start vibration:

_CTServerConnectionSetVibratorState(&x, connection, 3, intensity, 0, 0, 0);

stop vibration:

_CTServerConnectionSetVibratorState(&x, connection, 0, 0, 0, 0, 0);

This code is from HapticKeyboard, a downloadable application that buzzes the phone as you type. It is available for jailbroken phones on Cydia. See also my jailbreaking experience)

Any other good references?

kb

This will get your app rejected, though — because it uses private methods.
pop850
A: 

Has anybody tried this code? It does not work for me on 3.0.1. No vibrations.

connection = _CTServerConnectionCreate(kCFAllocatorDefault, &vibratecallback, &x);

vibrate on _CTServerConnectionSetVibratorState(&x, connection, 3, 10, 0, 0, 0);

//wait for 5 seconds

vibrate off

_CTServerConnectionSetVibratorState(&x, connection, 0, 0, 0, 0, 0);

neha
Tried this code, it doesn't work on iPhone OS 3.x. Is there any other method ?
Sney