前言
在开发中,有的时候为了统计用户信息、下发广告,服务器端往往需要手机用户设备及app的各种信息,这些信息的获取可以根据不同的设备或者App、系统版本来提供不同的功能或更好的用户体验,或者让开发者能更好的分析用户的问题原因。
下面讲述一下各种信息的获取方式:




点击下载以上展示效果的GitHub源码 ,大家也可以 本地下载
一行代码就搞定的统一来!
// 这个方法后面会列出来
NSString *deviceName = [self getDeviceName];
NSLog(@"设备型号-->%@", deviceName);
NSString *iPhoneName = [UIDevice currentDevice].name;
NSLog(@"iPhone名称-->%@", iPhoneName);
NSString *appVerion = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];
NSLog(@"app版本号-->%@", appVerion);
CGFloat batteryLevel = [[UIDevice currentDevice] batteryLevel];
NSLog(@"电池电量-->%f", batteryLevel);
NSString *localizedModel = [UIDevice currentDevice].localizedModel;
NSLog(@"localizedModel-->%@", localizedModel);
NSString *systemName = [UIDevice currentDevice].systemName;
NSLog(@"当前系统名称-->%@", systemName);
NSString *systemVersion = [UIDevice currentDevice].systemVersion;
NSLog(@"当前系统版本号-->%@", systemVersion);
struct utsname systemInfo;
uname(&systemInfo);
NSString *device_model = [NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding];
NSLog(@"device_model-->%@", device_model);
// 这个方法后面会单独列出
NSString *macAddress = [self getMacAddress];
NSLog(@"macAddress-->%@", macAddress);
// 这个方法后面会单独列出
NSString *deviceIP = [self getDeviceIPAddresses];
NSLog(@"deviceIP-->%@", deviceIP);
// 设备上次重启的时间
NSTimeInterval time = [[NSProcessInfo processInfo] systemUptime];
NSDate *lastRestartDate = [[NSDate alloc] initWithTimeIntervalSinceNow:(0 - time)];










