I've been incorporating NEHotspotHelper into my app that manages a captive network, but I'm having multiple issues. I'm not receiving an Authentication Command (kNEHotspotHelperCommandTypeAuthenticate) after my network that is set with a high level of confidence is in the Evaluating State. Also, my WISPr network is never receiving an Evaluate Command( kNEHotspotHelperCommandTypeEvaluate) when the SSID is selected in the Wi-Fi list in Settings. My goal for the WISPr Hotspot is to send a UINotification requiring a user action. ANyone know what I'm missing as far as not receiving kNEHotspotHelperCommandTypeAuthenticate & kNEHotspotHelperCommandTypeEvaluate in the two situations?
I set up HotspotHelper registerWithOptions in my app delegate as such:
NSMutableDictionary* options = [[NSMutableDictionary alloc] init];
[options setObject:@"Hotspot" forKey:kNEHotspotHelperOptionDisplayName];/
dispatch_queue_t queue = dispatch_queue_create("com.myapp.ex", 0);
BOOL returnType = [NEHotspotHelper registerWithOptions:options queue:queue handler: ^(NEHotspotHelperCommand * cmd) {
NEHotspotNetwork* network;
NSLog(@"COMMAND TYPE: %ld", (long)cmd.commandType);
if (cmd.commandType == kNEHotspotHelperCommandTypeEvaluate || cmd.commandType ==kNEHotspotHelperCommandTypeFilterScanList) {
for (network in cmd.networkList) {
NSLog(@"COMMAND TYPE After: %ld", (long)cmd.commandType);
if ([network.SSID isEqualToString:@"test-WPA-2"]|| [network.SSID isEqualToString:@"WISPr Hotspot"]) {
double signalStrength = network.signalStrength;
NSLog(@"Signal Strength: %f", signalStrength);
[network setConfidence:kNEHotspotHelperConfidenceHigh];
[network setPassword:@"myPassword"];
NEHotspotHelperResponse *response = [cmd createResponse:kNEHotspotHelperResultSuccess];
NSLog(@"Response CMD %@", response);
[response setNetworkList:@[network]];
[response setNetwork:network];
[response deliver];
}
}
}
}];
The first mistake I made in the code above: I was expecting the command type Evaluate to enumerate through the network list. However, the Evaluate command is actually looking to be delivered the connected network. I get the current network with the following code:
Then check to see if the connected list matches my SSID, if so I set the confidence level of this network and deliver the response to Evaluate:
The next command the handler is given is Authenticate. My complete code looks as following, I am still working on processing the commands after authenticate. The complete code line is: