Hi,
Recieved the NEHotspotHelper entitlement today and have been experimenting with it for almost 6 hours now. Got most of the parts working including auto-join for psk networks using passwords from the app. However when the network is a captive one, on which window should I present my custom view to interact with the captive portal? I tried it with UIApplication.sharedApplication as AppDelegate and used its window, but the app isn't pushed to the foreground. Is there a window on the Settings app on which I can present my UIVIewController because I've seen an app do this.Here is the snippet of my code.
switch command.commandType {
case .FilterScanList:
var networkListCanHandle = [NEHotspotNetwork]()
guard let networkList = command.networkList else {
print("No networks in the filter scan list")
return
}
for network in networkList {
network.setConfidence(.High)
networkListCanHandle.append(network)
}
let response = command.createResponse(.Success)
response.setNetworkList(networkListCanHandle)
response.deliver()
case .Evaluate:
guard let network = command.network else {
print("Network not present")
return
}
if network.SSID == "My Captive Portal" {
network.setConfidence(.High)
let response = command.createResponse(.Success)
response.setNetwork(network)
response.deliver()
}
case .Authenticate:
guard let network = command.network else {
print("Network not present")
return
}
if network.SSID == "My Captive Portal" {
network.setConfidence(.High)
let response = command.createResponse(.UIRequired)
response.setNetwork(network)
response.deliver()
}
case .PresentUI:
dispatch_async(dispatch_get_main_queue(), {
let customController: UIAlertController = UIAlertController(title: "Captive Login", message: "Let us handle the login", preferredStyle: .Alert)
// What should be the window here??
self.window?.rootViewController?.presentViewController(customController, animated: true, completion: nil)
})
case .Maintain:
break
case .Logoff:
break
case .None:
break
}