Currently only iPhone supports the vibrations how can I check if my device supports vibrations before calling the vibration function.
3 Answers
The iOS sdk has two functions that would vibrate the iPhone. But Vibration hardware is present only on iPhones. So how will you alert your user who uses the app on iPad or iPod touches? Clearly, checking the model is not the way to go. There are two seemingly similar functions that take a parameter kSystemSoundID_Vibrate
AudioServicesPlayAlertSound(kSystemSoundID_Vibrate);
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
Both the functions vibrate the iPhone. But when you use the first function on devices that don’t support vibration, it plays a beep sound. The second function on the other hand does nothing on unsupported devices.

- 22,743
- 12
- 84
- 133
-
how to overrule my default settings and play vibrate sound? is it possible or not? – Paras Gandhi Jan 09 '12 at 12:55
-
14This doesn't answer the question. Can someone please answer the question asked? This question was asked three times on SO and wasn't answered in any of them. – Daniel T. Aug 10 '12 at 18:59
-
Indeed, this does not answer the question. Bump. (the question is "if", not "how") – Jonny Mar 13 '13 at 09:47
-
3AudioServicesPlayAlertSound(kSystemSoundID_Vibrate); it does't make any beep sound on iPad and iPod. Vibrate on iPhone device, Nothing else. – Mangesh Jul 05 '14 at 07:46
-
AudioServicesPlayAlertSound doesn't seem to play a sound for me. – Jason Nov 11 '16 at 16:10
A bit of a work-around but I've found this to work. It's based on the assumption that only iPhone devices currently have the vibrate hardware in them.
if([[UIDevice currentDevice].model isEqualToString:@"iPhone"])
{
// An iPhone: so should have vibrate
}
else
{
// Not an iPhone: so doesn't have vibrate
}

- 3,776
- 1
- 16
- 27
-
1Might be a way to go but isn't canonical. As in, will iPad or iPod touch never have vibration? Will future hypotethical devices have vibration? If iPhone changes model name to "SuperDuperiPhone" this function also breaks. – Jonny Mar 13 '13 at 09:55
-
1Yeah you're totally right, but have to work with what the API has. Definitely think it's something that needs to be added into the SDK, some functionality to access all the availability of features on the current device. – Michael Mar 16 '13 at 00:23
Unfortunately there is no documented method for testing whether or not the device supports vibration. From documentation:
On some iOS devices, you can pass the kSystemSoundID_Vibrate constant to invoke vibration. On other iOS devices, calling this function with that constant does nothing.
Looks like the correct approach here would be to simply call the methods mentioned by Saurabh without checking if vibration is supported.

- 14,244
- 5
- 52
- 80