WiFi location principle and IOS WiFi list access

Source: Internet
Author: User
Tags bssid

WiFi location principle and IOS WiFi list access

For everyone, WiFi should be a familiar word, and we may be using WiFi hotspots every day. Wifi In addition to provide us with a focus on the role of positioning, now mobile devices to the user's privacy protection is increasingly strict, such as positioning function, must be authorized by the device user to use location to this device positioning. These strict privacy policies for users to protect, but to developers is a hindrance, in the case of strong demand for products users will be authorized, such as map applications, but others do not have a strong demand for positioning products, users may not give you authorization, which is we can consider the Wifi location.

Wifi Location principle

When we use the mobile phone to sweep the Wifi, we can actually locate the phone's location information. Each WiFi route is turned on, will not stop to send the signal around, we think of the WiFi route as the sun in a certain frequency to the surrounding electromagnetic radiation, electromagnetic waves will be weakened by the distance, but also because the object is blocked and weakened. Example is that we are in the same distance from the Wifi router, in some places the signal strength is high in some places the signal strength is low. Routing is also called a WiFi hotspot (or WiFi ap:access point). Every Wifi router will have a BSSID, many people call this BSSID MAC address (in fact, BSSID is not MAC address), BSSID set the general will not be in the change will not repeat, it means the world is the only, this is the rules of routing manufacturing, since there are rules then there will be People who do not obey the rules, the end of the article will introduce how people who do not obey the rules harm themselves.

Just mentioned BSSID, in the WiFi router is detected in the launch, while the WiFi routing signal is accompanied by the SSID (the name of the router: such as xx WiFi), signalstrength (mobile phone received WiFi signal strength) and other information. See here you should know how to use WiFi location, condition: the only constant bssid and the signal strength of the mobile phone to the router. IDEA: WiFi signal is a range, we assume that this range is 10 meters for a radius of a circle (the actual situation according to the WiFi routing vendors and routers around the environment), we go to collect some WiFi hotspot back, a fruit store WiFi, a restaurant WiFi and so on, We'll collect them ourselves. We certainly know their specific location, and the information mentioned in the Wifi: BSSID, SSID, Signalstrength, and then put them into the database, the collection of people can be many: professional collectors, taxi drivers, courier and so on, They often shuttle in the streets and alleys, in fact, each of us is a WiFi database collection personnel, our mobile phone manufacturers are silently collecting our location information, the iphone system settings can see where you go today, your WiFi connection which devices are also known. The longer the WiFi database information, the more you will eventually find each bssid will correspond to more than one SSID and signalstrength, because the SSID can be modified, signalstrength is collected in different locations around the WiFi hotspot, So the signal strength is also different. The more signal strength is collected, the more accurate the positioning of the BSSID is the WiFi hotspot.

Now if I go to a strange place, I open the phone scanning around the WiFi just scan to one or several, I put this wifi information (BSSID) to the server, the server through this BSSID to the database to find, can directly match to the corresponding location, return to me. If the match is not there is no one here to collect WiFi information, or the WiFi hotspot is recently arranged, collected personnel have not time to collect. The server can put these non-collected first classification later unified planning.

The overall function of Wifi positioning needs to be served by the service side, which means that there must be a network environment. In fact, mobile (mobile phone, pad, etc.) can also be done independently, but the technology and equipment hardware requirements will be much higher, the global Wifi hotspot is a very large amount of data, need to be high-precision lossless compression placed in the memory of a large mobile phone, perhaps many years later can be achieved (even if technically can be achieved, Benefits, risks, and workloads are a PK for product and research and development

IOS request to get Wifi list permission

Know the principle of what use, can achieve it? Okay, now we have a problem. Mobile devices are now mainly Andorid and iOS, Android can directly scan Wifi list to get relevant information, to find their own online, so that will not necessarily be the principle of technology implementation, I can only talk about IOS technology to achieve.
iOS get WiFi list In fact there are also a lot of restrictions, before iOS 9 can not get WiFi list, only to get the current connection WiFi information, also means only connected WiFi to locate, just said the scene is, I am in a strange principle, take out the mobile phone scanning Wifi, that is I'm not connected to the WiFi there (I don't know how to connect the password). Apple provides an API to get a WiFi list after IOS 9, but there is a threshold for getting a WiFi list, the main steps are:

  • 1. Apply to Apple to develop Network Extension permissions
  • 2. Apply for the description file containing Network Extension
  • 3, Configuration Info.plist
  • 4, configuration entitlements
  • 5. IOS Get Wifi List code implementation
  • 6. Get WiFi List callback
1. Apply to Apple to develop Network Extension permissions

First write an email to [email protected] , ask Apple to develop Network Extension permissions.
After receiving the email, Apple will automatically reply to the email and fill in the application form in https://developer.apple.com/contact/network-extension/, including:

Organization:company/product Url:what s your product ' s target market? What ' s your company ' s primary  function? describe your application and how it will use the network Extension framework. what type of  Entitlement are you requesting? ...  

You can receive Aplle confirmation letter about two weeks after the application, such as:

for your interest in the Network Extension APIs.We added a new template containing the Network Extension entitlements to your team.。。。。
2. Apply for the description file containing Network Extension

Select the profile that contains the Network Extension, and then click Download to complete the double-click Profile.

3, Configuration Info.plist

Xcode info.plist Required Background modes Add a network-authentication (item)

4, configuration entitlements

Demo.entitlements (Demo is the project name) add Key-value:com.apple.developer.networking.hotspothelper, yes

5. IOS Get Wifi List code implementation

Import Header File

#import <NetworkExtension/NetworkExtension.h>  

Code implementation

- (void) Getwifilist {if (![ [[uidevice Currentdevice] systemversion] floatvalue] >=  9.0) {return;} dispatch_queue_t queue = dispatch_queue_create ( " Com.leopardpan.HotspotHelper ", 0); [Nehotspothelper registerwithoptions:nil queue:queue handler: ^ (Nehotspothelpercommand * CMD) {if (Cmd.commandtype = = knehotspothelpercommandtypefilterscanlist) {for (nehotspotnetwork* network in cmd.networklist" {NSLog (@" network. SSID =%@ ", Network               

Knehotspothelpercommandtypefilterscanlist: Indicates the scan to Wifi list information.

The following information is available in Nehotspotnetwork:

  • Ssid:wifi Name
  • BSSID: MAC Address of the site
  • Signalstrength:wifi signal strength, which is between 0.0-1.0
  • Secure: The network is secure (no password is required for Wifi, this value is false)
  • Autojoined: The device is automatically connected to the WiFi, the current test automatically connected to the previously connected WiFi is also false.
  • Justjoined: Whether the network has just joined
  • Chosenhelper:hotspothelper is the selected assistant for the network

Official Document Connection

6. Get WiFi List callback

When you have finished writing the above code and successfully run the project, you find that there is no callback for the WiFi list. Because you haven't refreshed your WiFi list yet, you need to:

    • When you load the Wi-Fi list with WiFi on your phone system settings, the above Code section will callback to get to the WiFi list.

This time you'll be able to see a steady stream of logs from the console.

    • 1, get WiFi list function because it is necessary to apply for background permissions, so can activate the app (app), and the app after the activation of the process can survive for several hours.
    • 2, the entire access to the WiFi list does not require the app user authorization, that is, the app user is not aware of the device's WiFi list information, use, please use it properly.
    • 3, WiFi list get Networkextension is iOS 9 only out of the current, iOS 9 has been covered very wide.

Here's a list of statistics from TalkingData on iOS operating system, Date: 2017-01-03

Reference resources: Nehotspothelper networkextension API iOS9.0

WiFi location principle and IOS WiFi list access

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.