美文网首页
IOS 系统版本,手机序列号等相关知识

IOS 系统版本,手机序列号等相关知识

作者: 小暖风 | 来源:发表于2017-08-19 17:35 被阅读41次

    //手机序列号

    //手机别名:用户定义的名称

    NSString* userPhoneName = [[UIDevice currentDevice] name];

    NSLog(@"手机别名: %@", userPhoneName);

    //设备名称

    NSString* deviceName = [[UIDevice currentDevice] systemName];

    NSLog(@"设备名称: %@",deviceName );

    //手机系统版本

    NSString* phoneVersion = [[UIDevice currentDevice] systemVersion];

    NSLog(@"手机系统版本: %@", phoneVersion);

    //手机型号

    NSString* phoneModel = [[UIDevice currentDevice] model];

    NSLog(@"手机型号: %@",phoneModel );

    //地方型号(国际化区域名称)

    NSString* localPhoneModel = [[UIDevice currentDevice] localizedModel];

    NSLog(@"国际化区域名称: %@",localPhoneModel );

    NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];

    //当前应用名称

    NSString *appCurName = [infoDictionary objectForKey:@"CFBundleDisplayName"];

    NSLog(@"当前应用名称:%@",appCurName);

    //当前应用软件版本比如:1.0.1

    NSString *appCurVersion = [infoDictionary objectForKey:@"CFBundleShortVersionString"];

    NSLog(@"当前应用软件版本:%@",appCurVersion);

    //当前应用版本号码int类型

    NSString *appCurVersionNum = [infoDictionary objectForKey:@"CFBundleVersion"];

    NSLog(@"当前应用版本号码:%@",appCurVersionNum);

    //手机别名:用户定义的名称

    NSString* userPhoneName = [[UIDevice currentDevice] name];

    NSLog(@"手机别名: %@", userPhoneName);

    //设备名称

    NSString* deviceName = [[UIDevice currentDevice] systemName];

    NSLog(@"设备名称: %@",deviceName );

    //手机系统版本

    NSString* phoneVersion = [[UIDevice currentDevice] systemVersion];

    NSLog(@"手机系统版本: %@", phoneVersion);

    //手机型号

    NSString* phoneModel = [[UIDevice currentDevice] model];

    NSLog(@"手机型号: %@",phoneModel );

    //地方型号(国际化区域名称)

    NSString* localPhoneModel = [[UIDevice currentDevice] localizedModel];

    NSLog(@"国际化区域名称: %@",localPhoneModel );

    NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];

    //当前应用名称

    NSString *appCurName = [infoDictionary objectForKey:@"CFBundleDisplayName"];

    NSLog(@"当前应用名称:%@",appCurName);

    //当前应用软件版本比如:1.0.1

    NSString *appCurVersion = [infoDictionary objectForKey:@"CFBundleShortVersionString"];

    NSLog(@"当前应用软件版本:%@",appCurVersion);

    //当前应用版本号码int类型

    NSString *appCurVersionNum = [infoDictionary objectForKey:@"CFBundleVersion"];

    NSLog(@"当前应用版本号码:%@",appCurVersionNum);

    具体手机型号:

    - (NSString *)platform{

    size_t size;

    sysctlbyname("hw.machine", NULL, &size, NULL, 0);

    char *machine = malloc(size);

    sysctlbyname("hw.machine", machine, &size, NULL, 0);

    NSString *platform = [NSString stringWithCString:machine encoding:NSUTF8StringEncoding];

    free(machine);

    return platform;

    }

    或者

    + (NSString*)deviceVersion

    {

    //需要#import "sys/utsname.h"

    struct utsname systemInfo;

    uname(&systemInfo);

    NSString *deviceString = [NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding];

    //CLog(@"%@",deviceString);

    if ([deviceString isEqualToString:@"iPhone1,1"])    return @"iPhone 1G";

    if ([deviceString isEqualToString:@"iPhone1,2"])    return @"iPhone 3G";

    if ([deviceString isEqualToString:@"iPhone2,1"])    return @"iPhone 3GS";

    if ([deviceString isEqualToString:@"iPhone3,1"])    return @"iPhone 4";

    if ([deviceString isEqualToString:@"iPhone3,2"])    return @"Verizon iPhone 4";

    if ([deviceString isEqualToString:@"iPhone4,1"])    return @"iPhone 4S";

    if ([deviceString isEqualToString:@"iPhone5,2"])    return @"iPhone 5";

    if ([deviceString isEqualToString:@"iPhone6,2"])    return @"iPhone 5S";

    if ([deviceString isEqualToString:@"iPod1,1"])      return @"iPod Touch 1G";

    if ([deviceString isEqualToString:@"iPod2,1"])      return @"iPod Touch 2G";

    if ([deviceString isEqualToString:@"iPod3,1"])      return @"iPod Touch 3G";

    if ([deviceString isEqualToString:@"iPod4,1"])      return @"iPod Touch 4G";

    if ([deviceString isEqualToString:@"iPad1,1"])      return @"iPad";

    if ([deviceString isEqualToString:@"iPad2,1"])      return @"iPad 2 (WiFi)";

    if ([deviceString isEqualToString:@"iPad2,2"])      return @"iPad 2 (GSM)";

    if ([deviceString isEqualToString:@"iPad2,3"])      return @"iPad 2 (CDMA)";

    if ([deviceString isEqualToString:@"iPad3,4"])      return @"iPad 4 (WiFi)";

    if ([deviceString isEqualToString:@"i386"])         return @"Simulator";

    if ([deviceString isEqualToString:@"x86_64"])       return @"Simulator";

    //CLog(@"NOTE: Unknown device type: %@", deviceString);

    return deviceString;

    }

    相关文章

      网友评论

          本文标题:IOS 系统版本,手机序列号等相关知识

          本文链接:https://www.haomeiwen.com/subject/duntdxtx.html