获取wifi信息兼容iOS 14以上设备
This commit is contained in:
@@ -200,31 +200,21 @@ Strong UIButton *nextBtn;
|
||||
}
|
||||
-(void)connectMyWIFI{
|
||||
|
||||
NSUserDefaults*userDefsult=[NSUserDefaults standardUserDefaults];
|
||||
NSString*pass=[userDefsult objectForKey:@"wifiPass"];
|
||||
NSDictionary *netInfo = [self getSSIDInfo];
|
||||
_ssid = [netInfo objectForKey:@"SSID"];
|
||||
_bssid = [netInfo objectForKey:@"BSSID"];
|
||||
[CommonUtils getNetworkTypeComplete:^(NSString *netconnType, NSString *BSSID, NSString *SSID) {
|
||||
NSUserDefaults*userDefsult=[NSUserDefaults standardUserDefaults];
|
||||
NSString*pass=[userDefsult objectForKey:@"wifiPass"];
|
||||
|
||||
_ssid = SSID;
|
||||
_bssid = BSSID;
|
||||
|
||||
self.wifiPwdTextField.text=pass;
|
||||
self.wifiNameTextField.text = [netInfo objectForKey:@"SSID"];
|
||||
self.wifiPwdTextField.text=pass;
|
||||
self.wifiNameTextField.text = SSID;
|
||||
|
||||
}];
|
||||
}
|
||||
// refer to http://stackoverflow.com/questions/5198716/iphone-get-ssid-without-private-library
|
||||
//获取WiFi信息
|
||||
- (NSDictionary *)getSSIDInfo
|
||||
{
|
||||
NSArray *interfaceNames = CFBridgingRelease(CNCopySupportedInterfaces());
|
||||
NSDictionary *SSIDInfo;
|
||||
for (NSString *interfaceName in interfaceNames) {
|
||||
SSIDInfo = CFBridgingRelease(
|
||||
CNCopyCurrentNetworkInfo((__bridge CFStringRef)interfaceName));
|
||||
BOOL isNotEmpty = (SSIDInfo.count > 0);
|
||||
if (isNotEmpty) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return SSIDInfo;
|
||||
}
|
||||
|
||||
|
||||
#pragma mark --buttonClick
|
||||
-(void)nextBtnClick:(UIButton *)sender{
|
||||
BOOL isRight =[dataContorl isIncludeSpecialCharact:self.wifiPwdTextField.text];
|
||||
|
||||
Reference in New Issue
Block a user