2012-01-31 111 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"); 
} 

登錄頁面被阻止,但我的應用程序將不會被調用。讓我們分享經驗。謝謝