检测启用的wifi(不管它是否连接) [英] Detect wifi enabled (regardless of whether it's connected)

查看:132
本文介绍了检测启用的wifi(不管它是否连接)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于GPS追踪应用程序,开启WIFI的记录位置信号会导致真正不准确的数据或有差距的数据。

我已经使用Reachability查询来检测在开始追踪之前wifi是否可用。问题是,如果在查询时发现wifi已启用但未连接到网络,则表明互联网无法通过wifi访问,但这并不表示设置应用中的设置是否被禁用。这意味着如果用户开始运行并在中途连接,他们将从wifi而不是GPS或蜂窝网络获得位置信号。因此,这些数据点的准确度可以> 10米,所以我想跳过这一点。问题是,在wifi上,他们会有一个很大的空白时间,他们的信号没有被记录下来。



那我怎么检查wifi是否打开 / strong>但断开连接?

我已经阅读了所有我能找到的其他可达性讨论,但是这似乎是一个缺口,很多回应错误地暗示可达性解决了这个问题。



...并且我不打算要求 wifi - 只是提醒他们,因为它已启用,所以在某些时候他们的锻炼他们的位置数据可能会丢失(由于不准确)。

解决方案

只是遇到了这一个。



如果你想遵守苹果的规则,看起来没有什么办法可以做到这一点。 sysctl和ioctl将无法工作,因为没有标志会显示你是否启用了WiFi。例如,如果WiFi被禁用或WiFi已启用但未连接,则UP和RUNNING的标志将保持不变。

Apple自己的WiFi框架使用mach直接与内核沟通,我怀疑Apple会允许AppStore中的这些代码。


For a GPS tracking app, recording location signals with WIFI turned on results in really imprecise data or data with gaps.

I've used the Reachability queries to detect if wifi is available prior to starting tracking. The problem is that if when that query is made the wifi is enabled but not connected to a network, it shows that the internet is not reachable via wifi, but that's not an indication of if the setting is disabled in the settings app. This means that if the user starts running and a connection is made mid-run, they'll get a location signal from the wifi instead of the GPS or cell network. Consequently the accuracy on those data points can be > 10 meters so I want to skip that point. The issue is that on wifi they'll have a large blank period where their signal wasn't recorded.

So how can I check if wifi is enabled but disconnected?

I've read all the other reachability discussions I could find but this seems to be the one gap with lots of responses incorrectly suggesting that reachability solves this out of the box.

...and I'm not going to require wifi - just alert them to the fact that it is enabled so at some point in their workout their location data might be lost (due to inaccuracy).

解决方案

It's been quite a while since you asked, but I just came across this one.

It doesn't look like there is any way to do it if you want to obey Apple's rules. sysctl and ioctl won't work because there are no flags which will show you wether WiFi is enabled. For example the flags for "UP" and "RUNNING" will be the same if WiFi is disabled or WiFi is enabled but not connected.

Apple's own WiFi framework uses mach to directly communicate with the kernel and I doubt Apple would allows such code in the AppStore.

这篇关于检测启用的wifi(不管它是否连接)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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