Posts

Post marked as solved
4 Replies
1.4k Views
My App try to retrieve the ssid of the device to know if users are in the range of a store with hotspot. it's like geolocalisation but we also use it to optimize the experience of user when data is not available in indoor store.After iOS 12, we add in entitlements "Access WiFi Information", everything work correctly.According to iOS13 update, we have to respect at least one of criteria below to retrieve ssid* app must have permission to access location* enabled VPN app* NEHotspotCOnfigurationWe decide to use access location. When the application launch we request authorization for localisation, then, we try to retrieve the ssid, but CNCopyCurrentNetworkInfo always return an empty dictionnary even if CLAuthorisationStatus is equal to kCLAuthorizationStatusAuthorizedWhenInUse (user accept it)So, here is my code for detecting the current SSID:NSString *wifiName = [NSString stringWithFormat:@""]; CFArrayRef wifiInterfaces = CNCopySupportedInterfaces(); NSArray *interfaces = (__bridge NSArray *)wifiInterfaces; for (NSString *interfaceName in interfaces) { CFDictionaryRef dictRef = CNCopyCurrentNetworkInfo((__bridge CFStringRef)(interfaceName)); if (dictRef) { NSDictionary *networkInfo = (__bridge NSDictionary *)dictRef; wifiName = [NSString stringWithFormat:@"%@",[networkInfo objectForKey:(__bridge NSString *)kCNNetworkInfoKeySSID]]; } } return wifiName;The code will be called only when CLAuthorisationStatus is authorizeHere is a example:if (![CLLocationManager locationServicesEnabled]) { _locationManager.delegate = self; [_locationManager requestAlwaysAuthorization]; } else { CLAuthorizationStatus status = [CLLocationManager authorizationStatus]; if ((status!==kCLAuthorizationStatusRestricted) || (status!==kCLAuthorizationStatusDenied)) { // retrieve the ssid from the previous function } }
Posted
by Ekion.
Last updated
.