I have registered my app for using the Network Extension
API and enabled the background mode following the comments here. So, I am able to see the list of wifis on range when the user goes to the wifi settings, but I don't know why I am not able to set my custom sentence on the desired wifis and set the password.
NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:@"Try here", kNEHotspotHelperOptionDisplayName, nil];
dispatch_queue_t queue = dispatch_queue_create("com.myapp.ex", 0); // dispatch_get_main_queue()
BOOL isAvailable = [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:@"MySSID"]) {
[network setConfidence:kNEHotspotHelperConfidenceHigh];
[network setPassword:@"mypassword"];
// This is required
NEHotspotHelperResponse *response = [cmd createResponse:kNEHotspotHelperResultSuccess];
[response setNetwork:network];
[response deliver];
NSLog(@"Confidence set to high for ssid: %@ (%@)\n\n", network.SSID, network.BSSID);
}
}
}
}];
The SSID is matched, so the code is executed over the desired wifi and Try here
should appear under MySSID
on the wifi settings, and the password should be applied too, but none of both things are working.
Any idea about what's wrong on the code? Thanks