Detecting whether or not device support phone calls?
The iPhone supports the tel:// URI scheme. So you could use:
[[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"tel://"]];
canOpenURL: explicitly checks whether there's an application capable of opening that URL scheme, not that the URL is correct. So it doesn't matter that no phone number is specified. The method returns a BOOL, so check that for YES or NO.
That should literally answer whether there's any application present capable of making a telephone call. So it should be okay against any future changes in device segmentation.
Use jQuery to detect whether a device can make telephone calls (supports tel:// protocol)
I'm not sure about Android or BlackBerry, but iOS will automatically pick up telephone numbers and wrap them like so: <a href="tel:xxx">xxx</a>
...so you could have a hidden <div>
somewhere that contains a phone number like 1-800-555-5555, then, on page load do something like this:
var isTelephone = $("a[href*='tel:']").length > 0;
This may or may not be portable to other platforms, you'll have to try it out.
How to detect if device is capable of calling and messaging
Maybe you can query the PackageManager whether the system contains any component that can respond to ACTION_CALL and ACTION_SENDTO intents? You might need to add the "tel:" and "smsto:" scheme in the URI.
How to tell if Cocoa Touch device can make calls?
You could query [[UIDevice currentDevice] model]
, and check if it is an iPhone.
Detecting voice call support in mobile devices using titanium
Unfortunately there is no way to detect device capabilities. But there are several workarounds depending on what you want to do:
- You can create a wrapping method, that tries to detect the phone capability: On iOS this is easy, only the iPhone is able to do voice calls. On Android it's a bit different. Usually only handhelds can do phone calls but their are also some tablet devices that are able to.
- If you simply want to present a phone number that the user can klick on you can create a link with
Ti.Platform.openURL('callto:<number>');
. There is also acanOpenURL()
method - but its not available on android.
The canOpenURL()
method would be useful especially for android to determine whether the system is able to do phone calls or not. This question was also dicussed on Appcelerator Q&A.
Conclusion: Detecting capabilities needs to be solved on your own. In one of my apps i used the second solution regardless the device is able to do phone calls.
Related Topics
Autolayout - Make Height of View Relative to Half Superview Height
Creating and Playing a Sound in Swift
How to Determine If an Nsdate Is Today
Posting JSON Data Using Afnetworking 2.0
Does @Synchronized Guarantees for Thread Safety or Not
How to Add Equal Spacing and Equal Width for Button in iOS Auto Layout
Tweening/Interpolating Between Two Cgpaths/Uibeziers
Detecting iOS Uidevice Orientation
Get MAC Address of Bluetooth Low Energy Peripheral in iOS
Creating PDF File from Uiwebview
iOS 10 Error [Access] <Private> When Using Uiimagepickercontroller
How to Differentiate Between Iphone4 and iPhone 3
Force Landscape Mode in One Viewcontroller Using Swift
My App Was Just Rejected for Using the Ad Support Framework. Which Library Is Responsible
What Are the Device-Width CSS Viewport Sizes of the Iphone6 and iPhone 6 Plus