iPhone主动网络类型(2G,3G,WiFi) [英] iPhone active network type (2G, 3G, WiFi)

查看:159
本文介绍了iPhone主动网络类型(2G,3G,WiFi)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有谁知道如何确定特定时刻的有效网络类型: 2G 3G WiFi

Does anyone know how to determine the active network type at the specific moment: 2G, 3G or WiFi.

例如,在特定时刻可以启用 3G ,但使用的网络类型可能是 2G

For example, at a specific moment there could be enabled 3G, but the used network type could be 2G.

推荐答案

SCNetworkReachability 界面可以为您提供帮助。基本上,您创建一个所谓的可达性参考,然后在其上调用 SCNetworkReachabilityGetFlags 以获取有关连接的信息。

The SCNetworkReachability interface can help you with that. Basically, you create a so-called reachability reference and then call SCNetworkReachabilityGetFlags on it to get information about the connection.

返回的标志包括 kSCNetworkReachabilityFlagsIsWWAN ,它告诉您是通过WiFi还是通过蜂窝网络连接。但AFAIK不能用来说明2G和3G之间的区别。

The returned flags include kSCNetworkReachabilityFlagsIsWWAN, which tells you whether you are connected via WiFi or the cell network. AFAIK it cannot be used to tell the difference between 2G and 3G, though.

参见Apple的可达性示例应用,用于实施。在大多数情况下,您应该能够直接在项目中使用包含的 Reachability 类。

See Apple's Reachability sample app for an implementation. In most cases, you should be able to directly use the included Reachability class in your project.

这篇关于iPhone主动网络类型(2G,3G,WiFi)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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