How to get IOS hw.machine name

Hi All.

I do not like iPhone.generation…
How to get hw.machine name of С# or JS?

Of Obj-C you can so use this code…

-(void) getPlatform
{
 NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
 size_t size;
 sysctlbyname("hw.machine", NULL, &size, NULL, 0);
 char *machine = new char[size];
 sysctlbyname("hw.machine", machine, &size, NULL, 0);
    
    ////////////////////////////////////////////////////////////////////////////////////
	if (!strcasecmp(machine, "iPhone1,1"))         	{}  // "iPhone1G GSM"
	else if (!strcasecmp(machine, "iPhone1,2"))    	{}  // iPhone3G GSM"
	else if (!strcasecmp(machine, "iPhone2,1"))    	{}  // "iPhone3GS GSM"
	else if (!strcasecmp(machine, "iPhone3,1"))    	{}  // "iPhone4 GSM"; 
	else if (!strcasecmp(machine, "iPhone3,2"))    	{}  // "iPhone4 CDMAV"; 
	else if (!strcasecmp(machine, "iPhone3,3"))    	{}  // "iPhone4 CDMAS"
	else if (!strcasecmp(machine, "iPhone4,1"))    	{}  // "iPhone4S"
    else if (!strncmp(machine, "iPhone5", 7))		{}  // "iPhone5"
	else if (!strncmp(machine, "iPhone", 6))       	{}  // "UNKNOWN"
    //
	else if (!strcasecmp(machine, "iPod1,1"))      	{}  // "iPod 1G"
	else if (!strcasecmp(machine, "iPod2,1"))      	{}  // "iPod 2G"
	else if (!strcasecmp(machine, "iPod3,1"))      	{}  // "iPod 3G"
	else if (!strcasecmp(machine, "iPod4,1"))      	{}  // "iPod 4G"
	else if (!strcasecmp(machine, "iPod5,1"))   	{}  // "iPod 5G"
    else if (!strncmp(machine, "iPod", 4))          {}  // "UNKNOWN"
    //
    else if (!strncmp(machine, "iPad1", 5))         {}   // "iPad WiFi"
    else if (!strcasecmp(machine, "iPad2,1"))       {}   // "iPad2 WiFi"
    else if (!strcasecmp(machine, "iPad2,2"))       {}   // "iPad2 GSM"
    else if (!strcasecmp(machine, "iPad2,3"))       {}   // "iPad2 CDMAV"
    else if (!strcasecmp(machine, "iPad2,4"))       {}   // "iPad2 CDMAS"
    else if (!strcasecmp(machine, "iPad2,5"))       {}   // "iPad_MINI"
    else if (!strcasecmp(machine, "iPad2,6"))       {}   // "iPad_MINI"
    else if (!strcasecmp(machine, "iPad2,7"))       {}   // "iPad_MINI
    else if (!strncmp(machine, "iPad2", 5))        {}   // "iPad2 UNKNOWN"
    else if (!strcasecmp(machine, "iPad3,1"))       {}   // "iPad3 Wi-Fi"
    else if (!strcasecmp(machine, "iPad3,2"))       {}   // "iPad3 GSM"
    else if (!strcasecmp(machine, "iPad3,3"))       {}   // "iPad3 CDMA"
    else if (!strcasecmp(machine, "iPad3,4"))       {}   // "iPad4"
    else if (!strcasecmp(machine, "iPad3,5"))       {}   // "iPad4
    else if (!strcasecmp(machine, "iPad3,6"))       {}   // "iPad4
	else if (!strncmp(machine, "iPad3", 5))        {}   // "iPad3 UNKNOWN"
	else if (!strncmp(machine, "iPad", 4))         {}   // "UNKNOWN"
    //
 SAFE_DEL_ARRAY(machine);
 [pool release];
}

There is no way to do it in C# or JS in Unity. Your only hope is to have Unity Pro and call that native code from within Unity, returning back the device string.

You could just add a playerprefs key from Obj-C, sniffing that at start, then your C#/Unity code should be able to read the value.
I used this technique many times, and work great, with Unity Basic too.

for machine name : SystemInfo.deviceName
for machine model (iPhone3,1 or iPod4,1, etc) : SystemInfo.deviceModel
:slight_smile: