根据wwdc的要求CNCopyCurrentNetworkInfo这个接口符合以下三个条件才能获取当前的Wi-Fi名字:
- Apps with permission to access location
- Your app is the currently enabled VPN app
- Your app configured the WiFi network the device is currently using via NEHotspotConfiguration
最简单的是获取用户的地理位置权限;
CLLocationManager* _myLocationManager = [[CLLocationManager alloc] init];
_myLocationManager.delegate = self;
_myLocationManager.desiredAccuracy = kCLLocationAccuracyBest;//精确度
_myLocationManager.distanceFilter =1000.0f;//= 5;这个表示在地图上每隔1000m才更新一次定位信息。
[_myLocationManager requestWhenInUseAuthorization];//?只在前台开启定位
或者[_myLocationManager requestAlwaysAuthorization];