可达性飞行模式(3G)与Wifi [英] Reachability airplane mode (3G) vs. Wifi

查看:106
本文介绍了可达性飞行模式(3G)与Wifi的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道如果手机可以访问Wifi或3G网络,就会提供可达性代码.

I know the Reachability code will provide if the phone has access to Wifi or 3G network.

但是,如果手机已开启3G和Wifi,则可达性代码默认为说手机已开启Wifi,并且我无法检测到是否启用了3G网络(飞行模式已打开或关闭).

However, if the phone has 3G on and Wifi, the Reachability code defaults to saying the phone has Wifi on and I can't detect if 3G network is enabled or not (airplane mode on or off).

我需要特别确定在Wifi开启的情况下3G模式是打开还是关闭.

I need to find out specifically if 3G mode is on or off when Wifi is also on.

这是代码:

Reachability *reachability = [Reachability reachabilityForInternetConnection];
[reachability startNotifier];

NetworkStatus status = [reachability currentReachabilityStatus];

NSLog(@"status: %u", status);

if(status == NotReachable)  //status = 0
{
    //No internet
    NSLog(@"nothing is reachable");
}
if (status == ReachableViaWiFi) //status = 1
{
    //WiFi
    NSLog(@"Wifi is available");
}
if (status == ReachableViaWWAN) //status = 2
{
    //3G
    NSLog(@"3G is available");
}
NSLog(@"%@", s);

即使3G和Wifi处于打开状态,基本状态也将返回1.

Basically status is returning 1 even if the 3G is on as well as Wifi.

这可能吗?

我们将不胜感激.

推荐答案

当前,没有遵循Apple准则并在不使用其私有API的情况下在iPhone上执行此操作的方法.

Currently there is no way to do this on the iPhone following Apple guidelines and without using their private API.

这篇关于可达性飞行模式(3G)与Wifi的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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