Skip to content

Instantly share code, notes, and snippets.

@Axemasta
Created January 9, 2019 17:14
Show Gist options
  • Save Axemasta/29c0c3568bff10bc47cc7ca283145c3f to your computer and use it in GitHub Desktop.
Save Axemasta/29c0c3568bff10bc47cc7ca283145c3f to your computer and use it in GitHub Desktop.
Converts the iphone model strong (using GetSystemLibraryProperty("hw.machine") from a device code to a device model. Xamarin Essentials returns the code iPhone1,1 instead of iPhone 1, this method will convert it.
/// <summary>
/// Gets the device model from model code.
/// https://stackoverflow.com/questions/11197509/how-to-get-device-make-and-model-on-ios
/// </summary>
/// <returns>The device model.</returns>
/// <param name="modelCode">Model code.</param>
private string GetDeviceModel(string modelCode)
{
switch (modelCode)
{
case "iPhone1,1":
return "iPhone";
case "iPhone1,2":
return "iPhone 3G";
case "iPhone2,1":
return "iPhone 3GS";
case "iPhone3,1":
return "iPhone 4 (GSM)";
case "iPhone3,3":
return "iPhone 4 (CDMA/Verizon/Sprint)";
case "iPhone4,1":
return "iPhone 4S";
case "iPhone5,1":
return "iPhone 5 (model A1428, AT&T/Canada)";
case "iPhone5,2":
return "iPhone 5 (model A1429, everything else)";
case "iPhone5,3":
return "iPhone 5c (model A1456, A1532 | GSM)";
case "iPhone5,4":
return "iPhone 5c (model A1507, A1516, A1526 (China), A1529 | Global)";
case "iPhone6,1":
return "iPhone 5s (model A1433, A1533 | GSM)";
case "iPhone6,2":
return "iPhone 5s (model A1457, A1518, A1528 (China), A1530 | Global)";
case "iPhone7,1":
return "iPhone 6 Plus";
case "iPhone7,2":
return "iPhone 6";
case "iPhone8,1":
return "iPhone 6S";
case "iPhone8,2":
return "iPhone 6S Plus";
case "iPhone8,4":
return "iPhone SE";
case "iPhone9,1":
return "iPhone 7 (CDMA)";
case "iPhone9,3":
return "iPhone 7 (GSM)";
case "iPhone9,2":
return "iPhone 7 Plus (CDMA)";
case "iPhone9,4":
return "iPhone 7 Plus (GSM)";
case "iPhone10,1":
return "iPhone 8 (CDMA)";
case "iPhone10,4":
return "iPhone 8 (GSM)";
case "iPhone10,2":
return "iPhone 8 Plus (CDMA)";
case "iPhone10,5":
return "iPhone 8 Plus (GSM)";
case "iPhone10,3":
return "iPhone X (CDMA)";
case "iPhone10,6":
return "iPhone X (GSM)";
case "iPhone11,2":
return "iPhone XS";
case "iPhone11,4":
return "iPhone XS Max";
case "iPhone11,6":
return "iPhone XS Max China";
case "iPhone11,8":
return "iPhone XR";
default:
return "Unknown";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment