The first mistake I made in the above code: I was expecting the type of the Evaluate command to list through a list of networks. However, the Evaluate team actually wants to deliver the connected network. I get the current network with the following code:
NSArray *array = [NEHotspotHelper supportedNetworkInterfaces];
NEHotspotNetwork *connectedNetwork = [array lastObject];
NSLog(@"supported Network Interface: %@", connectedNetwork);
Then check if the connected list matches my SSID, so I set the trust level of this network and brought the response to Evaluate:
[connectedNetwork setConfidence:kNEHotspotHelperConfidenceLow];
[response setNetwork:connectedNetwork];
[response deliver];
The next command that the handler is given to is Authenticate. My complete code is as follows: I am still working on processing commands after authentication. Full line of code:
BOOL returnType = [NEHotspotHelper registerWithOptions:options queue:queue handler: ^(NEHotspotHelperCommand * cmd) {
NEHotspotNetwork* network;
if (cmd.commandType ==kNEHotspotHelperCommandTypeFilterScanList) {
for (network in cmd.networkList) {
if ([network.SSID isEqualToString:@"test-WPA-2"]) {
NSLog(@"%@", network.SSID);
NSLog(@"SSID is in Directory: %@", network.SSID);
double signalStrength = network.signalStrength;
NSLog(@"Signal Strength: %f", signalStrength);
[network setConfidence:kNEHotspotHelperConfidenceLow];
[network setPassword:@"password"];
NEHotspotHelperResponse *response = [cmd createResponse:kNEHotspotHelperResultSuccess];
NSLog(@"Response CMD %@", response);
[response setNetworkList:@[network]];
[response setNetwork:network];
[response deliver];
}
}
}
if (cmd.commandType == kNEHotspotHelperCommandTypeEvaluate) {
NSArray *array = [NEHotspotHelper supportedNetworkInterfaces];
NEHotspotNetwork *connectedNetwork = [array lastObject];
NSLog(@"supported Network Interface: %@", connectedNetwork);
NEHotspotHelperResponse *response = [cmd createResponse:kNEHotspotHelperResultSuccess];
NSLog(@"Response CMD %@", response);
[connectedNetwork setConfidence:kNEHotspotHelperConfidenceLow];
[response setNetwork:connectedNetwork];
[response deliver];
}
if (cmd.commandType == kNEHotspotHelperCommandTypeAuthenticate) {
NSLog(@"COMMAND TYPE In Auth ***********: %ld \n\n\n\n\n\n", (long)cmd.commandType);
}
if (cmd.commandType == kNEHotspotHelperCommandTypePresentUI) {
NSLog(@"COMMAND TYPE In Present UI ***********: %ld \n\n\n\n\n\n", (long)cmd.commandType);
}
}];
source
share