NEHotspotHelper NetworkExtension API iOS9.0

编程入门 行业动态 更新时间:2024-10-06 12:33:24
本文介绍了NEHotspotHelper NetworkExtension API iOS9.0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

We tried out the new NetworkExtention 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.developerworking.HotspotHelper' *作为其中一个权利。权利的值是布尔值 *值为真。

@note 2  *   The application MUST set 'com.apple.developerworking.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(cmdmandType == kNEHotspotHelperCommandTypeEvaluate || cmdmandType == kNEHotspotHelperCommandTypeFilterScanList ) {                  for (NEHotspotNetwork* network  in cmdworkList) {              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(cmdmandType == kNEHotspotHelperCommandTypeEvaluate || cmdmandType == kNEHotspotHelperCommandTypeFilterScanList) { for (NEHotspotNetwork* network in cmdworkList) { 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,

  • 您需要通过邮寄
  • 在Info.plist中,将 network-authentication 键添加到必需的背景模式数组 希望有所帮助。谢谢
  • you need to get entitlement access from apple by mailing them on networkextension@apple.
  • 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.
  • Add entitlement com.apple.developerworking.HotspotHelper to true in your entitlement file in your xcode
  • In Info.plist add network-authentication key to Required background modes array Hope that helps. Thanks
  • 更多推荐

    NEHotspotHelper NetworkExtension API iOS9.0

    本文发布于:2023-11-26 21:47:01,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1635319.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:NetworkExtension   NEHotspotHelper   API

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!