NEHotspotHelper注释没有出现 [英] NEHotspotHelper annotations not appearing

查看:335
本文介绍了NEHotspotHelper注释没有出现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

We tried out the new NetworkExtension API. We were successful in recreating all the steps in our app. But, we have an issue that we are still not seeing the custom annotation below the SSID name in the Wifi settings screen. We are on ios 9 Beta 3, xcode 7 beta 3.

我们已成功完成以下步骤:

We have done these steps successfully:


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

  • @note 1 The application's Info.plist MUST include a UIBackgroundModes array  *   containing 'network-authentication'.

@note 2
*申请必须设置'com.apple.developer.networking.HotspotHelper'
*作为其中一个权利。权利的值是布尔值
*值为真。

@note 2  *   The application MUST set 'com.apple.developer.networking.HotspotHelper'  *   as one of its entitlements. The value of the entitlement is a boolean  *   value true.

这是我们在应用程序中的代码。我们试图通过文本试试这里以Internet的名称来注释SSID。我们得到了为SSIDInternet调用setConfidence方法的日志。然而,我们没有在Wifi选择屏幕中看到实际的注释。

Here's our code in the App. We are trying to annotate a SSID by the name of "Internet" by a text "Try Here". We get the log that the setConfidence method is called for SSID "Internet". Yet, we do not see the actual annotation in the Wifi selection screen.

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

We also tried to pass 'nil' for the options object which promised to show the App name as the default annotation. But we do not see that either. We get return 'true' for the call to method registerWithOptions() and we do get callbacks when we open the wifi settings screen

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

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

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

请帮助我们了解我们缺少的东西?

Please help us to understand what we are missing ?

推荐答案

我已经在应用程序中使用连接到MyWifi为SSIDTP-LINK实现了以下代码来验证和注释Wifi热点,它工作正常。

I have implemented the below code for authenticating and annotating the Wifi hotspot with "Connect to MyWifi" for SSID "TP-LINK" from within the app, It works fine.

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

注意:要使上述代码生效,

Note: For the above code to work,


  1. 您需要通过邮寄

  2. 在Info.plist中,将 network-authentication 键添加到必需的背景模式数组

    希望有所帮助。谢谢

  1. you need to get entitlement access from apple by mailing them on networkextension@apple.com.
  2. Once you have the entitlement, you need to create new provisioning profile where you will have to add the network extension entitlement(available only if you have access) and use that profile in your xcode for it to work.
  3. Add entitlement com.apple.developer.networking.HotspotHelper to true in your entitlement file in your xcode
  4. In Info.plist add network-authentication key to Required background modes array Hope that helps. Thanks

这篇关于NEHotspotHelper注释没有出现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆