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

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

问题描述

以下代码是否可靠用于确定设备是否可以支持电话呼叫?
我关心的是如果apple将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,因此检查YES或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.

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

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