CNSetSupportedSSID返回false /无法正常工作?

时间:2012-01-31 17:39:48

标签: iphone

我尝试使用CaptiveNetwork来替换用于网络用户身份验证的网页。该方法是CNSetSupportedSSIDs。 我试图添加列表,但每次打开我的应用程序时,用户身份验证的网页仍然会弹出。 我试图调试它,我意识到我一直得到返回值为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 个答案:

答案 0 :(得分: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");
}

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