We tried out the new NetworkExtension API. We were successful in recreating all the steps in our app. But, we have an issue that we are still not seeing the custom annotatio
I have implemented the below code for authenticating and annotating the Wifi hotspot with "Connect to MyWifi" for SSID "TP-LINK" from within the app, It works fine.
NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:@"Connect to MyWifi", kNEHotspotHelperOptionDisplayName, nil];
dispatch_queue_t queue = dispatch_queue_create("com.myapp.ex", 0);
BOOL isAvailable = [NEHotspotHelper registerWithOptions:options queue:queue handler: ^(NEHotspotHelperCommand * cmd) {
NSMutableArray *hotspotList = [NSMutableArray new];
if(cmd.commandType == kNEHotspotHelperCommandTypeEvaluate || cmd.commandType == kNEHotspotHelperCommandTypeFilterScanList) {
for (NEHotspotNetwork* network in cmd.networkList) {
NSLog(@"network name:%@", network.SSID);
if ([network.SSID isEqualToString:@"TP-LINK"]) {
[network setConfidence:kNEHotspotHelperConfidenceHigh];
[network setPassword:@"<wifi-password>"];
[hotspotList addObject:network];
}
}
NEHotspotHelperResponse *response = [cmd createResponse:kNEHotspotHelperResultSuccess];
[response setNetworkList:hotspotList];
[response deliver];
}
}];
Note: For the above code to work,
You first need to register your app as Hotspot Helper via email https://forums.developer.apple.com/thread/11807
It seem it does not work exactly that way. A NEHotspotHelperCommand object actually expects a NEHotspotHelperResponse. You cannot modify the networks directly.
All your are missing in your code is the delivery of the NEHotspotHelperResponse.
NSMutableDictionary* options = [[NSMutableDictionary alloc] init];
[options setObject:@"Try Here" forKey:kNEHotspotHelperOptionDisplayName];
dispatch_queue_t queue = dispatch_queue_create("com.myapp.ex", 0);
BOOL returnType = [NEHotspotHelper registerWithOptions:options queue:queue handler: ^(NEHotspotHelperCommand * cmd) {
if (cmd.commandType == kNEHotspotHelperCommandTypeEvaluate || cmd.commandType == kNEHotspotHelperCommandTypeFilterScanList ) {
for (NEHotspotNetwork* network in cmd.networkList) {
if ([network.SSID isEqualToString:@"Internet"]) {
[network setConfidence:kNEHotspotHelperConfidenceHigh];
// This is required
NEHotspotHelperResponse *response = [cmd createResponse:kNEHotspotHelperResultSuccess];
[response setNetworkList:@[ network ]];
[response deliver];
NSLog(@"Confidance set to high for ssid:%@",network.SSID);
}
}
}
}];
Hope that helps. It's been over a month, but I just got cleared for this entitlement.