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

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

问题描述

以下代码是否可靠用于确定设备是否支持电话呼叫?我担心的是,如果苹果将 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.

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

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