In iOS development, sometimes we need to use some device-related information, the following is a detailed description of device-related information:
1. Get the current device owner name:
2. Get the category of the device, whether it's iphone,ipod or ipad
Here to get the specific type of iphone, you should have the following code:
-(NSString *) devicestring {//requires #import "sys/utsname.h" struct utsname systeminfo; Uname (&systeminfo); NSString *devicestring = [NSString stringWithCString:systeminfo.machine encoding:nsutf8stringencoding]; iphone 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,1"]) return @ "IPhone 5"; if ([devicestring isequaltostring:@ "iphone5,2"]) return @ "IPhone 5"; if ([devicestring isequaltostring:@ "iphone5,3"]) return @ "IPhone 5C"; if ([devicestring isequaltostring:@ "iphone5,4"]) return @ "IPhone 5C"; if ([DeviCestring isequaltostring:@ "iphone6,1"]) return @ "IPhone 5S"; if ([devicestring isequaltostring:@ "iphone6,2"]) return @ "IPhone 5S"; if ([devicestring isequaltostring:@ "iphone7,1"]) return @ "IPhone 6 Plus"; if ([devicestring isequaltostring:@ "iphone7,2"]) return @ "IPhone 6"; if ([devicestring isequaltostring:@ "iphone8,1"]) return @ "IPhone 6s"; if ([devicestring isequaltostring:@ "iphone8,2"]) return @ "IPhone 6s Plus"; ipod 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:@ "ipod5,1"]) return @ "IPod Touch 5G"; return nil;}
3. Device Localization Category:
4. Get the device's UUID:
5. Get the current phone running system and the current system version
The results are as follows:
Sometimes we also need to get information about the current app, such as the current app name, the current version number, to determine if the user should be prompted to upgrade the app.
The code is as follows:
IOS Device Information