Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Determining if device can vibrate - iPhone vs iPod Touch

Developing an app that vibrates when a particular event occurs. I have a setting for turning the vibrate option ON or OFF.

I would like to be able to disable the display of the vibrate setting for devices like the iPod Touch that do not have vibrate capability. I know I can do this by determining the device model using:

UIDevice *thisDevice = [UIDevice currentDevice];
    modelOfDevice = [thisDevice model];

I can then disable the Vibrate option depending on the modelOfDevice.. (i.e. not display it for iPod Touch). This works - but, I think it's bad form.. for example, if future iPod Touch devices do include Vibrate functionality, this solution would break.

So, the question.. How do I check to see if a device has the capability to vibrate??

Any suggestions appreciated. Thanks in advance.

like image 726
ReachWest Avatar asked Nov 15 '22 11:11

ReachWest


1 Answers

If you just use AudioServicesPlaySystemSound(kSystemSoundID_Vibrate) it vibrates where it can and does nothing where it cannot - just as the Apple documentation says, so you could skip the detection. The [article][1] says just can do AudioServicesPlayAlertSound(kSystemSoundID_Vibrate) to vibrate where possible or beep where not (iPod Touch still have beeping/keypress-click-sound ability)

[1]: http://blog.mugunthkumar.com/coding/iphone-tutorial-better-way-to-check-capabilities-of-ios-devices/ article

like image 151
PetrV Avatar answered Nov 30 '22 22:11

PetrV