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

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

问题描述

有谁知道如何确定特定时刻的活动网络类型:2G3GWiFi.

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 示例应用以了解实现.在大多数情况下,您应该能够直接在您的项目中使用包含的 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天全站免登陆