NEHotspotNetwork.fetchCurrent provides an object with always 0 signalStrength

I have this code:

import SwiftUI
import NetworkExtension
import CoreLocation

class WifiDataViewModel: NSObject, ObservableObject, CLLocationManagerDelegate {
    @Published var ssid: String = ""
    @Published var signalStrength: Double = 0
    
    private let locationManager = CLLocationManager()
    
    override init() {
        super.init()
        locationManager.delegate = self
        locationManager.requestWhenInUseAuthorization()
    }
    
    func fetchWifiData() {
        NEHotspotNetwork.fetchCurrent { network in
            guard let network else {
                print("No available network")
                return
            }
            self.ssid = network.ssid
            self.signalStrength = network.signalStrength
        }
    }
    
    // CLLocationManagerDelegate methods
    func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus) {
        if status == .authorizedWhenInUse || status == .authorizedAlways {
            fetchWifiData()
        }
    }
}

struct ContentView: View {
    @StateObject private var viewModel = WifiDataViewModel()
    
    var body: some View {
        VStack {
            Text("Wi-Fi Data")
                .font(.title)
                .padding()
            
            Text("Network SSID: \(viewModel.ssid)")
                .font(.subheadline)
            
            Text("Signal Strength: \(viewModel.signalStrength) dBm")
                .font(.subheadline)
            
            Button(action: {
                viewModel.fetchWifiData()
            }) {
                Text("Fetch Wi-Fi Data")
                    .font(.headline)
                    .padding()
                    .background(Color.blue)
                    .foregroundColor(.white)
                    .cornerRadius(10)
            }
        }
        .padding()
    }
}

The goal of this app is to find a weak spot in my home network, to manage router placement better.

I want to get wifi signal strength in any possible way, either it will be rssi value or [0, 1] value.

Documentation tells that signalStrength should provide such value, but it isn't. https://developer.apple.com/documentation/networkextension/nehotspotnetwork/1618923-signalstrength

From additional setup, Access Wi-Fi Information capability is granted.

iOS 16.4, Swift

please help me resolving this issue

This property is only populated in NEHotspotNetwork objects returned to hotspot helper apps [1]. Apps without the hotspot helper privilege always get back a dummy value (0.0 IIRC).

iOS does not have a general-purpose API for getting signal strength values. See iOS Network Signal Strength for more background on this.

Documentation tells that signalStrength should provide such value

I’d appreciate you filing a bug against the docs to cover this issue. Please make sure to reference this thread in your bug report.

Share and Enjoy

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

[1] Even then, a hotspot helper will only see it update if that helper was chosen for that network.

Thanks for a quick response.

I would be happy to find a way to do testing on a company testing device if this feature will function before requesting com.apple.developer.networking.HotspotHelper entitlement. Is there any way to do so?

Is there any way to do so?

No.

Having said that, Hotspot Helper is not going to fly here. Quoting its documentation:

NEHotspotHelper is only useful for hotspot integration. There are both technical and business restrictions that prevent it from being used for other tasks, such as accessory integration or Wi-Fi based location.

where hotspots are defined as:

Wi-Fi networks where the user must interact with the network to gain access to the wider Internet.

Share and Enjoy

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

NEHotspotNetwork.fetchCurrent provides an object with always 0 signalStrength
 
 
Q