NEHotspotHelper注释没有出现

san*_*osh 3 iphone objective-c ios networkextension

我们尝试了新的NetworkExtension API.我们成功地重新创建了应用程序中的所有步骤.但是,我们有一个问题,我们仍然没有在Wifi设置屏幕中看到SSID名称下面的自定义注释.我们在ios 9 Beta 3,xcode 7 beta 3上.

我们已成功完成这些步骤:

  • @note 1应用程序的Info.plist必须包含一个包含'network-authentication'的UIBackgroundModes数组*.

  • @note 2*应用程序必须将'com.apple.developer.networking.HotspotHelper'*设置为其权利之一.权利的值是布尔值*值true.

这是我们在App中的代码.我们试图通过文本"试试这里"以"Internet"的名称来注释SSID.我们得到了为SSID"Internet"调用setConfidence方法的日志.但是,我们在Wifi选择屏幕中看不到实际的注释.

我们还试图为选项对象传递'nil',该对象承诺将App名称显示为默认注释.但我们也没有看到.我们得到方法registerWithOptions()的调用返回'true',当我们打开wifi设置屏幕时我们得到回调

 

NSMutableDictionary* options = [[NSMutableDictionary alloc] init]; 
[options setObject:@"Try Here" forKey:kNEHotspotHelperOptionDisplayName]; 
 dispatch_queue_t queue = dispatch_queue_create("com.myapp.ex", 0); 
BOOL returnType = [NEHotspotHelper registerWithOptions:options queue:queue 
handler: ^(NEHotspotHelperCommand * cmd) { 
    if(cmd.commandType == kNEHotspotHelperCommandTypeEvaluate || cmd.commandType == kNEHotspotHelperCommandTypeFilterScanList ) { 
         
        for (NEHotspotNetwork* network  in cmd.networkList) {  
            if ([network.SSID isEqualToString:@"Internet"]){ 
                [network setConfidence:kNEHotspotHelperConfidenceHigh];               
                NSLog(@"Confidance set to high for ssid:%@",network.SSID); 
            }  
        }    
    } 
}];
Run Code Online (Sandbox Code Playgroud)

=========================

请帮助我们了解我们缺少的是什么?

sah*_*ain 6

我已经实现了以下代码,用于通过应用程序内的SSID"TP-LINK"的"连接到MyWifi"来验证和注释Wifi热点,它工作正常.

NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:@"Connect to MyWifi", kNEHotspotHelperOptionDisplayName, nil];

dispatch_queue_t queue = dispatch_queue_create("com.myapp.ex", 0);
BOOL isAvailable = [NEHotspotHelper registerWithOptions:options queue:queue handler: ^(NEHotspotHelperCommand * cmd) {
    NSMutableArray *hotspotList = [NSMutableArray new];

    if(cmd.commandType == kNEHotspotHelperCommandTypeEvaluate || cmd.commandType == kNEHotspotHelperCommandTypeFilterScanList) {
        for (NEHotspotNetwork* network  in cmd.networkList) {
            NSLog(@"network name:%@", network.SSID);
            if ([network.SSID isEqualToString:@"TP-LINK"]) {
                [network setConfidence:kNEHotspotHelperConfidenceHigh];
                [network setPassword:@"<wifi-password>"];                    
                [hotspotList addObject:network];
            }
        }

        NEHotspotHelperResponse *response = [cmd createResponse:kNEHotspotHelperResultSuccess];
        [response setNetworkList:hotspotList];
        [response deliver];
    }
}];
Run Code Online (Sandbox Code Playgroud)

注意:要使上述代码正常工作,

  1. 您需要通过networkextension@apple.com邮寄来获取苹果的权利访问权限.
  2. 获得权利后,您需要创建新的配置文件,您必须添加网络扩展权利(仅在您有权访问时可用)并在xcode中使用该配置文件才能使用.
  3. 在xcode的权利文件中将权限com.apple.developer.networking.HotspotHelper添加为true 在此输入图像描述
  4. 在Info.plist中,将网络身份验证密钥添加到必需的后台模式阵列 在此输入图像描述 希望有所帮助.谢谢

  • 怎么检查它是否没有进入你的区块?你有没有去过iOS Wifi设置并等待扫描wifi列表?在wifi设置中扫描wifi列表时调用块 (2认同)