Created
July 16, 2020 08:53
-
-
Save lewishalliday/9a107ff704bbee06984fcfe263389139 to your computer and use it in GitHub Desktop.
Xamarin Forms - Get iOS Device Model Pretty Name (i.e iPhone 11)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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