NEHotspotManager
A class that you use to enable or disable the hotspot evaluation and authentication provider extensions.
Declaration
final class NEHotspotManagerOverview
Use an NEHotspotManager to perform custom authentication of Wi-Fi hotspots in app extensions rather than in an app. Using sandboxed extensions is more performant and secure than performing hotspot authentication in an app.
The manager is responsible for two extensions:
An NEHotspotEvaluationProvider to evaluate detected Wi-Fi hotspots.
An NEHotspotAuthenticationProvider to authenticate with evaluated hotspots.
Implementing an evaluation provider
The NEHotspotEvaluationProvider managed by this class can receive a NEHotspotHelperCommandType.filterScanList command at any time. Respond to this by indicating which of the listed networks your provider can confidently handle.
When the device initially joins a network, the hotspot helper enters the evaluating state. In this state, each NEHotspotEvaluationProvider instance receives a command of type NEHotspotHelperCommandType.evaluate. If one or more evaluation providers indicates it can handle the network, the hotspot helper chooses the one with the highest confidence level before entering the authenticating state. If no evaluation provider instance claims the network, the state machine enters the authenticated state.
Using the state machine during authentication
In the authenticating state, your NEHotspotAuthenticationProvider receives the NEHotspotHelperCommandType.authenticate command. At this point, the provider performs any network processing needed to make the network available for general network traffic. If authentication is successful, your provider calls createResponse(_:) on the command to create a NEHotspotHelperResult.success response and returns it.
While in the authenticating state, if your authentication provider determines that it needs interaction from the person using the device, create an alert with UNUserNotificationCenter, and respond to the command with an NEHotspotHelperResult.uiRequired response. This transitions the state machine to a Presenting UI state, and the provider receives a command of type NEHotspotHelperCommandType.presentUI. The extension runs in the background in this state until the app collects the needed information from the person. After the app uses the information to complete the authentication, return a success response to enter the authenticated state.
After a successful authentication, the network enters a maintaining state when the network is joined again. In this state, the provider periodically receives the NEHotspotHelperCommandType.maintain command. To process this command, determine if the network remains able to carry general network traffic, and return success if this is the case. If not, and the network again requires authentication, return an NEHotspotHelperResult.authenticationRequired result.