NEHotspotHelper background

Hi,


I'm working on an app using the new NEHotspotHelper api to provide authentication for a particular wifi SSID.


I've acquired the required entitlements & set up the provisioning profile, specified network-authentication in the array of UIBackgroundModes key in the info.plist, and registered the app as a hotspot helper using the registerWithOptions:queue:handler: call.


My code gets executed OK when the app is running in the background (in app switcher), but when I force quit the app, it no longer gets woken up.

Is this expected behaviour, or am I doing something wrong with setting up the app to run in the background?


Thanks!

Replies

In general, terminating an app from the multitasking UI is considered by the system as a hint from the user that they don’t want the app to ever launch in the background again (this flag gets cleared when the user next manually launches the app). I’m not sure if this applies to hotspot helper code, but it seems likely.

If you want to test your app’s behaviour in the ‘launch in the background’ case, it’s best not to terminate the app that way. Rather, add a (debug only) button to your UI that calls

exit
, or simply hit the stop button in Xcode.

Share and Enjoy

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

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

Thanks for your reply eskimo.


Turns out it does seem to fully work in the background (after being force closed) afterall.


I had address sanitizer turned on, which was immediately crashing my app when not launched by the debugger (ie when iOS was trying to wake the app up to authenticate with the wifi).

For me it only calls kNEHotspotHelperCommandTypeEvaluate and kNEHotspotHelperCommandTypeFilterScanList all the time in background. My wifi network has both password protection and captive network also but I never get cmd.commandType == kNEHotspotHelperCommandTypeAuthenticate or kNEHotspotHelperCommandTypePresentUI called.


Is there any specific reason or way to call it?

For it to send you

.Authenticate
you have to respond to
.Evaluate
indicating that you can handle this network (and giving a confidence value). Do you do that?

Share and Enjoy

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

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

Dear Eskimo ,


I do have same issue I could receive kNEHotspotHelperCommandTypeEvaluate and kNEHotspotHelperCommandTypeFilterScanList in my code . But kNEHotspotHelperCommandTypeAuthenticate command never gets called . I am trying to connect captive newtwok ( i.e. public WiFi Hotspot) . The html login page is not coming at all .


How i can connect captive newtwok ( i.e. public WiFi Hotspot) programatically using NEHotspotHelper ? . Please provide sample code to be written for kNEHotspotHelperCommandTypeEvaluate command .

I responded on the other thread.

Share and Enjoy

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

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

I was also having an issue receiving kNEHotspotHelperCommandTypeAuthenticate. When my helper is in the Evaulating state, I check my connected network via [NEHotspotHelper supportedNetworkInterfaces] then compare that network to my list of networks that have a level of confidence. Once I deliever the response, the handler receives the Authenticate command. My code:

if (cmd.commandType == kNEHotspotHelperCommandTypeEvaluate) {
/ *   When a network is joined initially, the state machine enters
  
  *   the Evaluating state. In that state, each HotspotHelper receives a
  
  *   command of type Evaluate. If one or more helpers indicates that it
  
  *   is able to handle the network, the one with the highest confidence
  
  *   level is chosen before entering the Authenticating state. As an
  
  *   optimization, the first helper to assert a high confidence wins and
  
  *   the state machine ignores the other helpers.
  
  *
  
  *   If no helpers claim the network, the state machine enters the
  
  *   Authenticated state.
  
  */
  
NSLog(@"COMMAND TYPE In Evaluate ***********:   %ld \n\n\n\n\n\n", (long)cmd.commandType);
       
NEHotspotNetwork *connectedNetwork = [array lastObject];
            
NSLog(@"supported Network Interface: %@", connectedNetwork);
                   
if ([data isSSIDinDirectories:connectedNetwork.SSID]) {
                 
NEHotspotHelperResponse *response = [cmd createResponse:kNEHotspotHelperResultSuccess];
                 
NSLog(@"Response CMD Evaluate: %@", response);
                  
[connectedNetwork setConfidence:kNEHotspotHelperConfidenceLow];
[response setNetwork:connectedNetwork];        
[response deliver];             
}
         
}