did you know what am I missing in my code and settings when I try to call the registerWithOptions it always return false?
I already have the NetworkExtension Entitlement.
I've already created an Entitlement
And already created an array in .plist
here is my code:
NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:@"Try here", kNEHotspotHelperOptionDisplayName, nil];
dispatch_queue_t queue = dispatch_queue_create("com.myapp.ex", 0);
BOOL isAvailable = [NEHotspotHelper registerWithOptions:options queue:queue handler: ^(NEHotspotHelperCommand * cmd) {
NSLog(@"Sucessfully Registered");
}];
Check your app is signing with the correct entitlements file. You can do this with the following command:
codesign -d --entitlements :- /Users/User/Library/Developer/Xcode/DerivedData/appname-atpabrbgvqunorhiggpf/Build/Products/Debug-iphoneos/AppName.app
In the output, you should see the two following entitlements:
<key>com.apple.developer.networking.HotspotHelper</key>
<true/>
<key>com.apple.developer.networking.networkextension</key>
<array>
If you don't you can debug your codesigning process by following the thread here:
https://forums.developer.apple.com/message/75928#75928
Remember the hotspot helper code will only run on a device.
For reference, this code works for me (Swift)
var options = [String: NSObject]()
options[kNEHotspotHelperOptionDisplayName] = "Try Here" as NSObject?
NSLog("Lets register", "")
let returnType = NEHotspotHelper.register(options: options, queue: DispatchQueue.main, handler: {(_ cmd: NEHotspotHelperCommand) -> Void in
NSLog("Returned", "")
print(cmd)
if cmd.commandType == NEHotspotHelperCommandType.evaluate || cmd.commandType == NEHotspotHelperCommandType.filterScanList {
if cmd.networkList != nil {
for network: NEHotspotNetwork in cmd.networkList! {
NSLog("Found network \(network.bssid) with \(network.ssid)", "")
if (network.ssid == "Hub") {
print("Confidence set to high for ssid:\(network.ssid)")
}
}
}
}
})