iOS 13 Valid SSID and BSSID information from CNCopyCurrentNetworkInfo

As we announced at WWDC19, we're making changes to further protect user privacy and prevent unauthorized location tracking. Starting with iOS 13, the CNCopyCurrentNetworkInfo API will no longer return valid Wi-Fi SSID and BSSID information. Instead, the information returned by default will be:

SSID: “Wi-Fi” or “WLAN” (“WLAN" will be returned for the China SKU)

BSSID: "00:00:00:00:00:00"

If your app is using this API, we encourage you to adopt alternative approaches that don’t require Wi-Fi or network information. Valid SSID and BSSID information from CNCopyCurrentNetworkInfo will still be provided to VPN apps, apps that have used NEHotspotConfiguration to configure the current Wi-Fi network, and apps that have obtained permission to access user location through Location Services.

Test your app on the latest iOS 13 beta to make sure it works properly. If your app requires valid Wi-Fi SSID and BSSID information to function, you can do the following:

For accessory setup apps, use the NEHotSpotConfiguration API, which now has the option to pass a prefix of the SSID hotspot your app expects to connect to.

For other types of apps, use the CoreLocation API to request the user’s consent to access location information.

Learn more by reading the updated documentation or viewing the the Advances in Networking session video from WWDC19. You can also submit a TSI for code-level support.

方案:

CNCopyCurrentNetworkInfo

使用CNCopyCurrentNetworkInfo获取Wi-Fi名称:

+ (id)wifiSSID {idvalue =@"";NSArray*ifs = (__bridge_transferid)CNCopySupportedInterfaces();for(NSString*ifnaminifs) {NSDictionary*info = (__bridge_transferid)CNCopyCurrentNetworkInfo((__bridgeCFStringRef)ifnam);if(info[@"SSID"]) {                value = info[@"SSID"];            }        }if(!value || [value length]==0) {NSLog(@"get WiFi SSID Error!!");        }returnvalue;    }

iOS12之后获取Wi-Fi信息,需要另外申请证书配置

https://developer.apple.com/documentation/systemconfiguration/1614126-cncopycurrentnetworkinfo

你可能感兴趣的:(iOS 13 Valid SSID and BSSID information from CNCopyCurrentNetworkInfo)