在項(xiàng)目開發(fā)中有時(shí)我們需要獲得設(shè)備或app的一些信息并傳遞給后臺(tái)课竣,一下是我總計(jì)的一些方法有需要的同學(xué)可以參考一下的
UIDevice *device = [[UIDevice alloc]init];
//? ? 獲取設(shè)備所有者的名稱
NSLog(@"設(shè)備所有者名稱:%@",device.name);
//? ? 獲取設(shè)備的類別
NSLog(@"設(shè)備類別:%@",device.model);
//? ? 本地化版本
NSLog(@"本地化版本:%@",device.localizedModel);
//? ? 獲取當(dāng)前版本
NSLog(@"當(dāng)前系統(tǒng)版本? %@",device.systemVersion);
//? ? 獲取當(dāng)前系統(tǒng)
NSLog(@"當(dāng)前系統(tǒng)? %@",device.systemName);
//? ? 獲取唯一表示符ID
NSLog(@"系統(tǒng)唯一標(biāo)示符? %@",[[[UIDevice currentDevice ] identifierForVendor] UUIDString]);
//? ? 檢測(cè)真機(jī)模擬還是模擬器:輸出-1為模擬器戚篙,輸出0-1為真機(jī)
NSLog(@"電量? %f",[[UIDevice currentDevice] batteryLevel]);
//? ? 獲取當(dāng)前語言
NSArray *languageArray = [NSLocale preferredLanguages];
NSString *language = [languageArray objectAtIndex:0];
NSLog(@"語言:%@", language);
//? ? 獲取當(dāng)前的國別
NSLocale *locale = [NSLocale currentLocale];
NSString *country = [locale localeIdentifier];
NSLog(@"國家:%@", country); //國別
//? ? 獲取運(yùn)營商消息
CTTelephonyNetworkInfo *infomation = [[CTTelephonyNetworkInfo alloc] init];
//? ? 獲取運(yùn)營商的名稱
CTCarrier *carrier = [infomation subscriberCellularProvider];
NSString *mCarrier = [NSString stringWithFormat:@"%@",[carrier carrierName]];
NSLog(@"%@", mCarrier);
#pragma mark App應(yīng)用相關(guān)參數(shù)獲取
NSDictionary *dicInfo = [[NSBundle mainBundle] infoDictionary];
NSLog(@"應(yīng)用所有信息 %@",dicInfo);
NSString *strAppName = [dicInfo objectForKey:@"CFBundleDisplayName"];
NSLog(@"App應(yīng)用名稱:%@", strAppName);
NSString *strAppVersion = [dicInfo objectForKey:@"CFBundleShortVersionString"];
NSLog(@"App應(yīng)用版本:%@", strAppVersion);
NSString *strAppBuild = [dicInfo objectForKey:@"CFBundleVersion"];
NSLog(@"App應(yīng)用Build版本:%@", strAppBuild);
NSString *strAppBundleIdentifier = [dicInfo objectForKey:@"CFBundleIdentifier"];
NSLog(@"App應(yīng)用唯一標(biāo)示符:%@", strAppBundleIdentifier);
參考代碼連接:https://github.com/wangningsai/GetPhoneInformation