NEHotspotHelper (NetworkExtension iOS9.0) Sample code

Hi,

I would like to achive below tasks in my app ,

1) Annotate Wifi networks in the WiFi network scanner (Display WiFi networks in the iOS X network scanner with a little tag that displays something (your company name, for example) under the SSID name.)

2) Authenticate for WiFi Hotspots in backgorund .


I am able see my binary signed with NEHotspotHelper Entitlements also i have added network-authentication background mode to the Info.plist

Referred link https://forums.developer.apple.com/thread/9015 , https://forums.developer.apple.com/message/30660#30660


My current code is pasted below . registerWithOptions is returning true and handler code is called in backgorund and when user scans Wifi list .


NSDictionary* options = [NSDictionary dictionaryWithObjectsAndKeys:@"Connect Here",kNEHotspotHelperOptionDisplayName, nil];

dispatch_queue_t queue = dispatch_queue_create("com.my.NewtworkExt", 0);


BOOL returnType = [NEHotspotHelper registerWithOptions:options queue:queue handler: ^(NEHotspotHelperCommand * cmd) {


if(cmd.network) {

NEHotspotNetwork* network = cmd.network;

if( (cmd.commandType == kNEHotspotHelperCommandTypeEvaluate || cmd.commandType == kNEHotspotHelperCommandTypeFilterScanList ) {

[network setConfidence:kNEHotspotHelperConfidenceHigh];

}

}

}];


Please provide me some sample code/ steps to achive above tasks.

Replies

What is cmd ?

cmd
is a
NEHotspotHelperCommand
value.

ps If you’re just getting started with

NEHotspotHelper
, you might find my NEHotspotHelper pseudo API post helpful.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Did you able to find the solution for this? Please let me know as I am facing the same issue. NEHotspotHelperCommandType.authenticate never called. I have asked the same question in the old thread


https://forums.developer.apple.com/thread/51545

Hello All,
I'm using NEHotspotConfigurationManager with on iOS 11 iPhone to connect to specific Wi-Fi.

Here is the code:


let domainName = ""
let hotspotSettings = NEHotspotHS20Settings.init(domainName: domainName, roamingEnabled: true)
let hotspotEAPSettings = NEHotspotEAPSettings()
hotspotEAPSettings.username = *****
hotspotEAPSettings.password = ******
hotspotEAPSettings.isTLSClientCertificateRequired = true
hotspotEAPSettings.supportedEAPTypes = [21]
hotspotEAPSettings.trustedServerNames = [""]
hotspotEAPSettings.ttlsInnerAuthenticationType = .eapttlsInnerAuthenticationMSCHAPv2
print(hotspotEAPSettings)
let hotspotConfig = NEHotspotConfiguration.init(hs20Settings: hotspotSettings, eapSettings: hotspotEAPSettings)
print( hotspotConfig.ssid)
NEHotspotConfigurationManager.shared.apply(hotspotConfig) {[unowned self] (error) in
print(error?.localizedDescription as Any)// gives Error Domain=NEHotspotConfigurationErrorDomain Code=5 "invalid EAP settings."
print(error as Any)
if let error = error {
self.showError(error: error)
} else {
self.showSuccess()
}
}

Question is: what happened? Why it prompts me error "invalid EAP settings", and also what does this error mean?
Please go on :

NEHotspotConfigurationErrorDomain Code=5 “invalid EAP settings.”

Please open a new thread for this question. You’re working with

NEHotspotConfigurationManager
and this thread is about
NEHotspotHelper
, and those are very different APIs.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"