WiFi开启时如何在iPhone中获取移动数据状态 [英] How to get Mobile data status in iPhone when WiFi is ON

查看:80
本文介绍了WiFi开启时如何在iPhone中获取移动数据状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当前,我正在使用iPhone应用程序,该应用程序需要显示移动数据状态(开/关).对于使用reachability类的网络检查即时通讯,但是当启用任何一个网络(即WiFi/移动数据)时,它都能为我提供正确的结果,但是如果同时启用这两个功能,它都将给出Wifi状态,但我的要求是我只需要移动数据状态还.如果有人建议我解决方案,那就太好了.

Currently i am working on an iPhone Application which needs to display the mobile data status(ON/OFF). For network check im using Reachability class but it is giving me correct result when any one of the networks are enable i.e WiFi/Mobile Data, but if both are enable it is giving Wifi status, but my requirement is i just need to mobile data status also. It would be great if anyone suggest me solution.

谢谢

推荐答案

遗憾的是,似乎无法在打开WiFi时检查移动数据是否已打开.您可以检测是否有WiFi连接,是否没有WiFi连接但有移动数据连接或是否根本没有连接.但是,如果有WiFi连接,似乎也无法检测是否有数据连接.

Sadly, there seems to be no way to check that mobile data is turned on when WiFi is turned on. You can detect whether there is a WiFi connection, whether there is no WiFi connection but a mobile data connection, or whether there is no connection at all. But if there is a WiFi connection, there seems to be no way to detect whether there is a data connection as well.

使用电话分类,您可以检测设备是否具有SIM卡,还可以检测是否已在应用程序的设置"中禁用了移动数据.据我所知,您无法检测到是否为整个设备启用了移动数据.

Using the telephony classes, you can detect whether the device has a SIM card, and you can detect whether mobile data has been disabled in Settings for your application. You can not detect as far as I know whether mobile data is enabled for the whole device.

您也无法区分Wifi已关闭,WiFi已打开但附近没有网络或未选择网络以及飞行模式已开启.

You can also not distinguish between Wifi turned off, WiFi turned on but no network nearby or selected, and Airplane mode turned on.

这篇关于WiFi开启时如何在iPhone中获取移动数据状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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