Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why NEHotspotHelper registerWithOptions returning FALSE?

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 enter image description here

And already created an array in .plist enter image description here

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");
}];
like image 247
Tristan Angelo C. Galang Avatar asked Dec 10 '25 02:12

Tristan Angelo C. Galang


1 Answers

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)")
                        }
                    }

                }



            }
        })
like image 52
Gmeister4 Avatar answered Dec 11 '25 15:12

Gmeister4



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!