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)
=========================
请帮助我们了解我们缺少的是什么?
我已经实现了以下代码,用于通过应用程序内的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)
注意:要使上述代码正常工作,

希望有所帮助.谢谢| 归档时间: |
|
| 查看次数: |
13319 次 |
| 最近记录: |