// 使用NSLocale类
NSLocale *currentLocale = [NSLocale currentLocale]
NSLog(@"Country Code is %@", [currentLocale objectForKey:NSLocaleCountryCode]);
NSLog(@"Language Code is %@", [currentLocale objectForKey:NSLocaleLanguageCode]);
// 上面这个类在使用的过程中,很不准确,比方你按home键之后,更改语言为 english<之前为中文>,然后在代码里使用上面这个类获取的语言仍然是中文,而不是英文,并且修改区域同样出问题
// 获取准确的语言设置
NSString* strLanguage = [[[NSUserDefaults standardUserDefaults] objectForKey:@"AppleLanguages"] objectAtIndex:0];
// 跳转系统设置wifi页面
if ([[UIDevice currentDevice].systemVersion doubleValue] >= 10.0) {
// iOS10及以上
NSURL *wifiURL = [NSURL URLWithString:@"App-Prefs:root=WIFI"];
if ([[UIApplication sharedApplication] canOpenURL:wifiURL]) {
[[UIApplication sharedApplication] openURL:wifiURL];
}
} else {
// iOS8-10
NSURL *wifiURL = [NSURL URLWithString:@"prefs:root=WIFI"];
if ([[UIApplication sharedApplication] canOpenURL:wifiURL]) {
[[UIApplication sharedApplication] openURL:wifiURL];
}
}
// iOS10及以后
// 无线局域网 App-Prefs:root=WIFI
// 蓝牙 App-Prefs:root=Bluetooth
// 蜂窝移动网络 App-Prefs:root=MOBILE_DATA_SETTINGS_ID
// 个人热点 App-Prefs:root=INTERNET_TETHERING
// 运营商 App-Prefs:root=Carrier
// 通知 App-Prefs:root=NOTIFICATIONS_ID
// 通用 App-Prefs:root=General
// 通用-关于本机 App-Prefs:root=General&path=About
// 通用-键盘 App-Prefs:root=General&path=Keyboard
// 通用-辅助功能 App-Prefs:root=General&path=ACCESSIBILITY
// 通用-语言与地区 App-Prefs:root=General&path=INTERNATIONAL
// 通用-还原 App-Prefs:root=Reset
// 墙纸 App-Prefs:root=Wallpaper
// Siri App-Prefs:root=SIRI
// 隐私 App-Prefs:root=Privacy
// Safari App-Prefs:root=SAFARI
// 音乐 App-Prefs:root=MUSIC
// 音乐-均衡器 App-Prefs:root=MUSIC&path=com.apple.Music:EQ
// 照片与相机 App-Prefs:root=Photos
// FaceTime App-Prefs:root=FACETIME
// iOS10之前
// 蜂窝网络:prefs:root=MOBILE_DATA_SETTINGS_ID
// Wi-Fi:prefs:root=WIFI
// 定位服务:prefs:root=LOCATION_SERVICES
// 个人热点:prefs:root=INTERNET_TETHERING
// 关于本机:prefs:root=General&path=About
// 辅助功能:prefs:root=General&path=ACCESSIBILITY
// 飞行模式:prefs:root=AIRPLANE_MODE
// 锁定:prefs:root=General&path=AUTOLOCK
// 亮度:prefs:root=Brightness
// 蓝牙:prefs:root=Bluetooth
// 时间设置:prefs:root=General&path=DATE_AND_TIME
// FaceTime:prefs:root=FACETIME
// 设置:prefs:root=General
// 设置 prefs:root=SETTING
// 定位服务 prefs:root=LOCATION_SERVICES
// 键盘设置:prefs:root=General&path=Keyboard
// iCloud:prefs:root=CASTLE
// iCloud备份:prefs:root=CASTLE&path=STORAGE_AND_BACKUP
// 语言:prefs:root=General&path=INTERNATIONAL
// 定位:prefs:root=LOCATION_SERVICES
// 音乐:prefs:root=MUSIC
// iOS 10之前:prefs iOS 10:App-Prefs
// About — prefs:root=General&path=About
// Accessibility — prefs:root=General&path=ACCESSIBILITY
// Airplane Mode On — prefs:root=AIRPLANE_MODE
// Auto-Lock — prefs:root=General&path=AUTOLOCK
// Brightness — prefs:root=Brightness
// Bluetooth — prefs:root=General&path=Bluetooth
// Date & Time — prefs:root=General&path=DATE_AND_TIME
// FaceTime — prefs:root=FACETIME
// General — prefs:root=General
// Keyboard — prefs:root=General&path=Keyboard
// iCloud — prefs:root=CASTLE
// iCloud Storage & Backup — prefs:root=CASTLE&path=STORAGE_AND_BACKUP
// International — prefs:root=General&path=INTERNATIONAL
// Location Services — prefs:root=LOCATION_SERVICES
// Music — prefs:root=MUSIC
// Music Equalizer — prefs:root=MUSIC&path=EQ
// Music Volume Limit — prefs:root=MUSIC&path=VolumeLimit
// Network — prefs:root=General&path=Network
// Nike + iPod — prefs:root=NIKE_PLUS_IPOD
// Notes — prefs:root=NOTES
// Notification — prefs:root=NOTIFICATIONS_ID
// Phone — prefs:root=Phone
// Photos — prefs:root=Photos
// Profile — prefs:root=General&path=ManagedConfigurationList
// Reset — prefs:root=General&path=Reset
// Safari — prefs:root=Safari
// Siri — prefs:root=General&path=Assistant
// Sounds — prefs:root=Sounds
// Software Update — prefs:root=General&path=SOFTWARE_UPDATE_LINK
// Store — prefs:root=STORE
// Twitter — prefs:root=TWITTER
// Usage — prefs:root=General&path=USAGE
// VPN — prefs:root=General&path=Network/VPN
// Wallpaper — prefs:root=Wallpaper
// Wi-Fi — prefs:root=WIFI
/**
获取当前wifi名称
@return wifi热点名称字符串
*/
- (NSString *)getWifiName {
NSString *wifiName = @"未连接";
NSArray *myArray = (id)CFBridgingRelease(CNCopySupportedInterfaces());
if (myArray.count > 0) {
NSDictionary *info = (id)CFBridgingRelease(CNCopyCurrentNetworkInfo((CFStringRef)([myArray firstObject])));
if (info[@"SSID"]) {
wifiName = [info valueForKey:@"SSID"];
NSLog(@"wifiName:%@", wifiName);
}
}
return wifiName;
}
网友评论