2012-01-31 108 views
1

我试图使用CaptiveNetwork来替换网络用户认证的网页。该方法是CNSetSupportedSSIDs。 我试着添加列表,但用户身份验证的Web表格每次打开我的应用程序时都会弹出。 我试图调试它,我意识到我不断得到返回值为FALSE。CNSetSupportedSSID返回false /无法正常工作?

这是我的代码:

-(void)updateSSIDlist 

{ 
[[NSNotificationCenter defaultCenter] postNotificationName:@"ssidInitStarted" object:nil userInfo:nil]; 
ATT_Remote_Access_Wifi_ClientAppDelegate *delegate = (ATT_Remote_Access_Wifi_ClientAppDelegate *)[[UIApplication sharedApplication] delegate]; 

delegate.ssidInitFinished = NO; 
Hotspots *h = [Hotspots defaultHotspots]; 
NSArray *ssids2 = [h uniqueSSIDs]; 
NSLog(@"ssids we're shoving down into the system config for iOS to leave alone: %@", [ssids2 description]); 

bool ok = CNSetSupportedSSIDs((CFArrayRef) ssids2); 

if(ok) 
{ 
    [[NSNotificationCenter defaultCenter] postNotificationName:@"ssidInitCompleted" object:nil userInfo:nil]; 
NSLog(@"completed");  
} 
else 
{ 
[[NSNotificationCenter defaultCenter] postNotificationName:@"ssidInitFailed" object:nil userInfo:nil]; 
NSLog(@"failed"); 
} 

delegate.ssidInitFinished = YES; 
delegate.dbIsBusy = NO; 
} 

我搜索了很多,但我无法找到任何这正确的实例或文件。 我也尝试了下面的链接示例,但即使这样也重新获得了相同的结果。

任何帮助被赞赏!谢谢!

回答

1
NSString *values[] = {@"yourssid"};  
CFArrayRef arrayRef = CFArrayCreate(kCFAllocatorDefault, (void *)values, (CFIndex)1, &kCFTypeArrayCallBacks);  
if(CNSetSupportedSSIDs(arrayRef)) 
{ 
    NSLog(@"Successfully registered supported network SSIDs"); 
} 
else 
{ 
    NSLog(@"Error: Failed to register supported network SSIDs"); 
} 

登录页面被阻止,但我的应用程序将不会被调用。让我们分享经验。谢谢