HotspotHelper API

I'm interested in examples which show how to use the new NEHotspotHelper API.

Anyone tried it yet and can post an example?


I would like to clarify whether it can be used to provision a hotspot SSID that the app is interested in but never entered by the user or provisioned any other way (e.g. mobileprovision download or MDM).

Replies

I've used it. The handler gets called when the user is on the WiFi settings page, and as of beta 2 its called every scan for the first 3 scans then every 3rd scan. I can't get it to call the handler under any other circumstance, including WiFi off/on, Airplane mode, ask to join networks. Also re-registering the handler multiple times has no effect.


[NEHotspotHelper registerWithOptions:nil queue:dispatch_get_main_queue() handler:^(NEHotspotHelperCommand * __nonnull cmd) {

NSLog(@"commandType %d", cmd.commandType);

NSLog(@"network %@", cmd.network);

NSLog(@"network list %@", cmd.networkList);

}];


2015-07-15 11:10:04.388 HotspotTest[301:12809] commandType 1

2015-07-15 11:10:05.841 HotspotTest[301:12809] network <CNNetwork SSID (null) BSSID (null) [open] [signal 0] 0x14d88790>

2015-07-15 11:10:09.182 HotspotTest[301:12809] network list (

"<CNNetwork SSID BTWifi-with-FON BSSID 42:f2:1:21:f8:a4 [open] [signal 0.19302] 0x14d770c0>",

"<CNNetwork SSID BTWifi-X BSSID 62:f2:1:21:f8:a4 [protected] [signal 0.217848] 0x14d7dbf0>",

"<CNNetwork SSID BTHub5-XQMT BSSID 0:f2:1:21:f8:a4 [protected] [signal 0.231553] 0x14d8d410>",

"<CNNetwork SSID BTHomeHub-A9BF BSSID 0:1d:68:82:4:a5 [protected] [signal 0.246163] 0x14d596c0>",

"<CNNetwork SSID BTWiFi BSSID 2:1d:68:82:4:a6 [open] [signal 0.261706] 0x14d8dca0>",

"<CNNetwork SSID agate BSSID 90:72:40:1f:61:8a [protected] [signal 0.261706] 0x14d7d7a0>",

"<CNNetwork SSID agate-garden BSSID 0:1c:b3:aa:e0:39 [protected] [signal 0.511782] 0x14d56220>",

"<CNNetwork SSID SKYA8CA3 BSSID c0:3e:f:33:d7:31 [protected] [signal 0.98226] 0x14d7c4f0>",

"<CNNetwork SSID BTWifi-with-FON BSSID 42:f2:1:21:f8:a4 [open] [signal 0.19302] 0x14d655c0>",

"<CNNetwork SSID BTWifi-X BSSID 62:f2:1:21:f8:a4 [protected] [signal 0.217848] 0x14d78490>",

"<CNNetwork SSID BTHub5-XQMT BSSID 0:f2:1:21:f8:a4 [protected] [signal 0.231553] 0x14d8d850>",

"<CNNetwork SSID BTHomeHub-A9BF BSSID 0:1d:68:82:4:a5 [protected] [signal 0.246163] 0x14d8dfe0>",

"<CNNetwork SSID BTWiFi BSSID 2:1d:68:82:4:a6 [open] [signal 0.261706] 0x14d53de0>"

)

(lldb)

Does this code still work in the latest beta? I've been trying to get the current SSID and I only get NIL and the code above never calls the callback.


I tried calling


NSArray * networkInterfaces = [NEHotspotHelper supportedNetworkInterfaces];


in the current beta as of July 26th and it just returns nil. Thanks

Pretty sure you need additional entitlements added to your a/c. The following link goes into this in a little more detail. https://forums.developer.apple.com/thread/9015


With the correct entitlements, and carefully following the steps detailed in the NEHotspotHelper.h header file, the code above does work (as does your example code). Though in both cases, this obviously only works on the simulator.

Hi ,

I am able see my binary signed with NEHotspotHelper Entitlements also i have added network-authentication background mode to the Info.plist . I would like to achive below things 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 .


My current code is pasted below . registerWithOptions is returning true .


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];

}

}

}];


Is anything i am missing over here ?

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


Thanks

I saw the entitlements piece, but i wanted to know if that small snippet would work without it. Basically the old way of getting the network information isn't working in iOS 9


CFArrayRef ifs = CNCopySupportedInterfaces();


That's without compiling and running on an iOS 9 device. Just installing an app that i has that code, that works under iOS 8 and prior with no extra entitlements. I already filed a bug, but I wanted to check with someone that does have the entitilements to see if it is also a bug for them in the current beta. This is the first beta for iOS 9 that i have tried it on and so I didn't know if it happened in the prior betas too.

sandi,


I've replied to that in another thread:

https://forums.developer.apple.com/message/31150


Works for me.