如何在IOS中查看网络2G或3G? [英] How to check network 2G or 3G in IOS?

查看:35
本文介绍了如何在IOS中查看网络2G或3G?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想检查设备是否有 2G 或 3G 连接.

I want to check if the device has a 2G or 3G connection.

我使用 Reachability 类进行网络连接检查.

I used Reachability class for network connection check.

推荐答案

在 iOS 7 中,Apple 提供了一种获取它的新方法.

In iOS 7 Apple provided a new way to get it.

请阅读此链接.了解您的收音机"部分.

Please read this link. The "Know your Radio" section.

基本思路是使用新的

当前无线电接入技术

添加到 CTTelephonyNetworkInfo 类.如果您想在每次连接更改时收到通知,您可以监听:

added to the CTTelephonyNetworkInfo class. If you want to get notified everytime the connection changes you can listen for:

CTRadioAccessTechnologyDidChangeNotification

CTRadioAccessTechnologyDidChangeNotification

这是从提供的链接中获取的代码片段:

Heres a code snippet took from the provided link:

CTTelephonyNetworkInfo *telephonyInfo = [CTTelephonyNetworkInfo new];
NSLog(@"Current Radio Access Technology: %@", telephonyInfo.currentRadioAccessTechnology);
[NSNotificationCenter.defaultCenter addObserverForName:CTRadioAccessTechnologyDidChangeNotification 
                                            object:nil 
                                             queue:nil 
                                        usingBlock:^(NSNotification *note) 
{
    NSLog(@"New Radio Access Technology: %@", telephonyInfo.currentRadioAccessTechnology);
}];

我希望这对你有帮助.

这篇关于如何在IOS中查看网络2G或3G?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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