1.获取手机系统版本:NSString* phoneVersion = [[UIDevice currentDevice] systemVersion];
2.获取手机类型:NSString* phoneModel = [self iphoneType];//方法在下面
3.获取手机系统:NSString * iponeM = [[UIDevice currentDevice] systemName];
4.获取电池电量:CGFloat batteryLevel=[[UIDevicecurrentDevice]batteryLevel];
5.获取手机版本号
导入头文件:import<sys/utsname.h>
struct utsname systemInfo;
uname(&systemInfo);
NSString *platform = [NSString stringWithCString:systemInfo.machine encoding:NSASCIIStringEncoding];
if ([platform isEqualToString:@"iPhone1,1"]) ->iPhone 2G;
if ([platform isEqualToString:@"iPhone1,2"]) ->iPhone 3G
if ([platform isEqualToString:@"iPhone2,1"]) ->iPhone 3GS
if ([platform isEqualToString:@"iPhone3,1"]) ->iPhone 4
if ([platform isEqualToString:@"iPhone3,2"]) ->iPhone 4
if ([platform isEqualToString:@"iPhone3,3"]) ->iPhone 4
if ([platform isEqualToString:@"iPhone4,1"]) ->iPhone 4S
if ([platform isEqualToString:@"iPhone5,1"]) ->iPhone 5
if ([platform isEqualToString:@"iPhone5,2"]) ->iPhone 5
if ([platform isEqualToString:@"iPhone5,3"]) ->iPhone 5c
if ([platform isEqualToString:@"iPhone5,4"]) ->iPhone 5c
if ([platform isEqualToString:@"iPhone6,1"]) ->iPhone 5s
if ([platform isEqualToString:@"iPhone6,2"]) ->iPhone 5s
if ([platform isEqualToString:@"iPhone7,1"]) ->iPhone 6 Plus
if ([platform isEqualToString:@"iPhone7,2"]) ->iPhone 6
if ([platform isEqualToString:@"iPhone8,1"]) ->iPhone 6s
if ([platform isEqualToString:@"iPhone8,2"]) ->iPhone Plus
if ([platform isEqualToString:@"iPhone8,4"]) ->iPhone SE
if ([platform isEqualToString:@"iPhone9,1"]) ->iPhone 7
if ([platform isEqualToString:@"iPhone9,2"]) ->iPhone Plus
if ([platform isEqualToString:@"iPod1,1"]) ->iPod Touch 1G
if ([platform isEqualToString:@"iPod2,1"]) ->iPod Touch 2G
if ([platform isEqualToString:@"iPod3,1"]) ->iPod Touch 3G
if ([platform isEqualToString:@"iPod4,1"]) ->iPod Touch 4G
if ([platform isEqualToString:@"iPod5,1"]) ->iPod Touch 5G
if ([platform isEqualToString:@"iPad1,1"]) ->iPad 1G
if ([platform isEqualToString:@"iPad2,1"]) ->iPad 2
if ([platform isEqualToString:@"iPad2,2"]) ->iPad 2
if ([platform isEqualToString:@"iPad2,3"]) ->iPad 2
if ([platform isEqualToString:@"iPad2,4"]) ->iPad 2
if ([platform isEqualToString:@"iPad2,5"]) ->iPad Mini 1G
if ([platform isEqualToString:@"iPad2,6"]) ->iPad Mini 1G
if ([platform isEqualToString:@"iPad2,7"]) ->iPad Mini 1G
if ([platform isEqualToString:@"iPad3,1"]) ->iPad 3
if ([platform isEqualToString:@"iPad3,2"]) ->iPad 3
if ([platform isEqualToString:@"iPad3,3"]) ->iPad 3
if ([platform isEqualToString:@"iPad3,4"]) ->iPad 4
if ([platform isEqualToString:@"iPad3,5"]) ->iPad 4
if ([platform isEqualToString:@"iPad3,6"]) ->iPad 4
if ([platform isEqualToString:@"iPad4,1"]) ->iPad Air
if ([platform isEqualToString:@"iPad4,2"]) ->iPad Air
if ([platform isEqualToString:@"iPad4,3"]) ->iPad Air
if ([platform isEqualToString:@"iPad4,4"]) ->iPad Mini 2G
if ([platform isEqualToString:@"iPad4,5"]) ->iPad Mini 2G
if ([platform isEqualToString:@"iPad4,6"]) ->iPad Mini 2G
if ([platform isEqualToString:@"i386"]) ->iPhone Simulator
if ([platform isEqualToString:@"x86_64"]) ->iPhone Simulator
网友评论