检测设备是否支持电话? [英] Detecting whether or not device support phone calls?

查看:79
本文介绍了检测设备是否支持电话?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下代码是否可靠用于确定设备是否可以支持电话?
我担心的是,如果苹果将iphone字符串更改为其他任何东西,我们可以说他们决定使用iphone 3g,iphone 4等。

Is the below code reliable to be used to determine whether a device can support phone calls or not? My concern is if apple changes the iphone string to anything else let's say they decide to have "iphone 3g", "iphone 4" etc.

[[UIDevice currentDevice].model isEqualToString:@"iPhone"]


推荐答案

iPhone支持tel:// URI方案。所以你可以使用:

The iPhone supports the tel:// URI scheme. So you could use:

[[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"tel://"]];

canOpenURL:明确检查是否有能够打开该URL方案的应用程序,而不是URL是否正确。所以没有指定电话号码并不重要。该方法返回BOOL,因此请检查是否为NO。

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.

这篇关于检测设备是否支持电话?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆