问题
Is it possible to make the phone to "know" that a specific wifi network is at specific geographic location?
if (answer == YES)
{
than how?
}
else
{
can the phone figure this out by himself?
}
Another similar question: is there any way to start monitor a region with accuracy of ~100m but telling the CLLocationManager to use only by wifi networks and cellular antenas? Because I don't want to power up the GPS no matter what...
Thanks!
回答1:
iPhone positioning sucks and there is nothing you can do.
If you jailbreak your device you can use the Apple80211 private framework to look up the available Wi-Fi networks and their signal strength. But that also means your app will get rejected.
If the user manually connects to a Wi-Fi you can see the MAC addresses of the devices on that network and use that to guess your position. Since Wi-Fi has a range of 50 meters, that's the accuracy you get.
All the positioning system is transparent for an App Store developer, meaning an application can't disable the GPS, list Wi-Fis, or read the signal strength. The most you can do is guess if you are positioning through GPS or Wi-Fi looking at the altitude parameter.
Use case: You are in a mall and you want to know where shop X is. Probably there is no GPS signal, and if you install a GPS repeater you get the position of the antenna of that repeater, not your position. Even if you install a dozen Wi-Fi access points you can't ask the user to manually connect because it's a hassle, and even if he did he would get 50-100 meters accuracy, and then there is the security risk of connecting here and there. Basically you are screwed.
回答2:
I completely agree with Jano: apple logic has more sense than other solutions. Anyway You can easy get your WIFI network id:
-(void)LogInfo:(NSDictionary*)info forKey:(NSString*)key;
{
NSString* temp;
temp = [info objectForKey: key];
NSLog(temp);
}
- (void)fetchSSIDInfo
{
NSArray *ifs = (id)CNCopySupportedInterfaces();
NSDictionary* info = nil;
for (NSString *ifnam in ifs)
{
info = (id)CNCopyCurrentNetworkInfo((CFStringRef)ifnam);
NSString *temp = [NSString stringWithFormat:@"%@", [info description]];
[self AddToLog: temp];
[self LogInfo:info forKey:@"BSSID"];
[self LogInfo:info forKey:@"SSID"];
[self LogInfo:info forKey:@"SSIDDATA"];
[info release];
}
[ifs release];
}
来源:https://stackoverflow.com/questions/6341547/ios-can-i-manually-associate-wifi-network-with-geographic-location