Skip to content

Instantly share code, notes, and snippets.

@lewishalliday
Created July 16, 2020 08:53
Show Gist options
  • Save lewishalliday/9a107ff704bbee06984fcfe263389139 to your computer and use it in GitHub Desktop.
Save lewishalliday/9a107ff704bbee06984fcfe263389139 to your computer and use it in GitHub Desktop.
Xamarin Forms - Get iOS Device Model Pretty Name (i.e iPhone 11)
public class DeviceModel
{
public string GetDevice()
{
try
{
if (Device.RuntimePlatform == Device.iOS)
{
var json = new WebClient().DownloadString("https://raw.githubusercontent.com/fieldnotescommunities/ios-device-identifiers/master/ios-device-identifiers.json");
var values = JsonConvert.DeserializeObject<Dictionary<string, string>>(json);
var deviceName = values[DeviceInfo.Model];
return deviceName;
}
else
return DeviceInfo.Model;
}
catch
{
return DeviceInfo.Model;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment