WiFi access has been declined

Hi, I'm unable to get access to wifi information. My provisioning profile includes "Access WiFi Information" and entitlements include "com.apple.developer.networking.wifi-info". And yet I'm getting an exception "CoarseReloc: WiFi access has been declined" In Xcode UI "Signing & Capabilities" I see "Access WiFi Information" but there is no switch to enable/disable it. XCode version 12.4

What else do I need to set up?

What API are you using to request Wi-Fi information?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

What is the most straightforward official apple API to test it out

See CNCopyCurrentNetworkInfo() (link) and NEHotspotNetwork.fetchCurrent() (link).

In particular, note the requirements listed in the first linked page. Have you confirmed at least one of them is satisfied? Usually this means the user needs to give authorization to access their location.

 there is absence of a switch next to Access WiFi Information. Is it expected?

Yes. If an entitlement or capability is listed there, then you have it.

I have a Mac mini (2012) with macOS Catalina 10.15.7. So NEHotspotNetwork.fetchCurrent() is not available. Here is my test code:

mLocationManager = CLLocationManager()
mLocationManager!.delegate = self
mLocationManager!.requestAlwaysAuthorization()
...
func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus) {
     print("status: \(status.rawValue)")
     let interfaces = CNCopySupportedInterfaces() as NSArray?
     print("interfaces: \(interfaces!.count)")
     let interface = interfaces![0] as! CFString
     print("interface: [\(interface)]")
     let info = CNCopyCurrentNetworkInfo(interface) as NSDictionary?
     if (info == nil) {
         print("info: nil")
     } else {
         print("info: not nil")
     }
}
// OUTPUT:
status: 0 (notDetermined)
interfaces: 1
interface: [en0]
2022-08-03 10:43:23.335260+0100 DimensionX[3066:1830775] [] nehelper sent invalid result code [1] for Wi-Fi information request
info: nil

Here’s a problem:

// OUTPUT:
status: 0 (notDetermined)

At this point the user has not yet authorized you to access their location, so CNCopyCurrentNetworkInfo won’t work, as documented. (I’m assuming your app doesn’t happen to meet one of the other requirements that would allow it to work.) This first call to locationManager(_:didChangeAuthorization:) may just be the result of creating your CLLocationManager object, where it helpfully informs you what the initial authorization status is.

You need to wait for the user to actually authorize the location access (via the prompt presented by requestAlwaysAuthorization) which will then call your locationManager(_:didChangeAuthorization:) again with the updated status. After that happens, CNCopyCurrentNetworkInfo should work as expected.

I'm not getting any prompt. Calling requestAlwaysAuthorization() in viewDidLoad of my view

class ARViewCtrl: UIViewController, MTKViewDelegate, UITextInputTraits, CLLocationManagerDelegate {
...
}

Why doesn't this prompt appear?

The problem is solved. I changed requestAlwaysAuthorization() tp requestWhenInUseAuthorization() and added NSLocationWhenInUseUsageDescription to info.plist. Once the prompt showed up everything started to work including the SpatialAnchors lib. Thanks for helping me!

WiFi access has been declined
 
 
Q