我们尝试了新的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,
更多推荐
NEHotspotHelper NetworkExtension API iOS9.0
发布评论