Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get available WiFi list with NEHotspotHelper (IOS, objective-c)

I have already done this.

1. Add IOS certificate in Apple Developer page.

2. Add identifiers App IDs with Network Extension enabled in Apple Developer page.

3. Add provisioning profile in Apple Developer page.

4. Create the Xcode project and type the correct bundle ID which made on the apple developer page. And sign right team.

5. Add capabilities and library (Network Extension framework).

6. After 5, Entitlement file is generated automatically in my Xcode project.

7. At last time I wrote the code like this.

NSLog(@"List Scan START");

NSMutableDictionary* options = [[NSMutableDictionary alloc] init];
    [options setObject:@"Try Here" forKey:kNEHotspotHelperOptionDisplayName];
    dispatch_queue_t queue = dispatch_queue_create("com.miro.wifilist", 0);

    BOOL isAvailable = [NEHotspotHelper registerWithOptions:options queue:queue handler: ^(NEHotspotHelperCommand * cmd) {
        if (cmd.commandType == kNEHotspotHelperCommandTypeEvaluate || cmd.commandType == kNEHotspotHelperCommandTypeFilterScanList ) {
            for (NEHotspotNetwork* network in cmd.networkList) {
                NSLog(@"%@", network.SSID);
            }
        } else {
            NSLog(@"there is no available wifi");
        }
    }];

if (isAvailable) {
    NSLog(@"true");
} else {
    NSLog(@"false");
}

NSLog(@"List scan END");
return @"";

But I can't get any wifi list. In my source, variable "isAvailable" is returned false.

To resolve this problem I tried this additionally.

Add "com.apple.developer.networking.HotspotHelper" with boolean type and "true"

-> result of this: I can build the project, but I can't install the app on my device. I get an error message like this "The executable was signed with invalid entitlements".

I don't know why is not working.

Do I miss something to authenticate to use the Network Extension library or NEHotspotHelper?? Or is there any error in my source??

** After I requested the Network Extension library to apple, I got the message like this from apple.

message content from apple


Thank you for requesting information about the Network Extension framework. Please note that as of November 10, 2016, this process is not required for developers who wish to use App Proxy, Content Filter, or Packet Tunnel APIs. To use these services please navigate to your Developer Account at https://developer.apple.com/account/ and select the Network Extension capability for the App ID you will be using for your app.

If you are requesting an entitlement for Hotspot Helper APIs your request will be addressed at our earliest convenience.

Regards,

Developer Technical Support

Apple Worldwide Developer Relations


like image 264
Kim sunny Avatar asked Oct 30 '22 00:10

Kim sunny


2 Answers

It's worth highlighting that it's not actually possible to get a list of available Wifi hotspots on an iOS device. Please have a read of this post:

Apple Developer Forums: List available wifi network

like image 81
Leon Avatar answered Nov 09 '22 10:11

Leon


  1. You need to complete a questionnaire at https://developer.apple.com/contact/network-extension, and then you can use NEHotspotHelper to return a list of hotspots.
  2. Apple sends this message: enter image description here
  3. In your provisioning profile settings in Apple Developer page take an expanded view (Add "com.apple.developer.HotspotHelper" with boolean type and "true"), how this enter image description here
like image 29
Vkrotin Lexys Avatar answered Nov 09 '22 10:11

Vkrotin Lexys