views:

113

answers:

2

I want to offer phone support in my app at the press of a button for iPhone users, and display a phone number for iPad/iPod Touch users. Rather than detecting what device the user has, is there a better way to query the hardware to see if it has telephony capabilities? This would continue to work should iPad 3G one day open up for voice calls.

I am aware of how to limit an app to devices through the UIRequiredDeviceCapabilities key, but I'm not looking to restrict platform, just detect capabilities.

+6  A: 

Check if application can open tel url:

if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"tel:+11111"]])
  // device has phone capabilities
Vladimir
Thanks - this looks to be exactly what I'm looking for (minor revision to [NSURL URLWithString:@"tel:+11111"]). I have only tested on iPhone so far, but the simulator reports that it can't make calls whilst the real device claims that it can! Many thanks to both respondents!
Purpletoucan
yes, sorry - mistyped a string
Vladimir
A: 

Here is some code written by Max Horváth, that detects the device model. I didn't test it so far but my search gives me that result

http://www.iphone4gapp.net/device-detection.html

Ifi
Note that it's better to check for specific capability (eg: checking if the OS responds to the `tel://` URL) rather than an actual device model, since some users may have features disabled. For example, an old iPhone that now doesn't have cell connectivity.
Michael Grinich