Xamarin.Essentials: Device Information
The DeviceInfo class provides information about the device the application is running on.
Add a reference to Xamarin.Essentials in your class:
The following information is exposed through the API:
// Device Model (SMG-950U, iPhone10,6) var device = DeviceInfo.Model; // Manufacturer (Samsung) var manufacturer = DeviceInfo.Manufacturer; // Device Name (Motz's iPhone) var deviceName = DeviceInfo.Name; // Operating System Version Number (7.0) var version = DeviceInfo.VersionString; // Platform (Android) var platform = DeviceInfo.Platform; // Idiom (Phone) var idiom = DeviceInfo.Idiom; // Device Type (Physical) var deviceType = DeviceInfo.DeviceType;
DeviceInfo.Platform correlates to a constant string that maps to the operating system. The values can be checked with the
- DeviceInfo.Platforms.iOS – iOS
- DeviceInfo.Platforms.Android – Android
- DeviceInfo.Platforms.UWP – UWP
- DeviceInfo.Platforms.Unsupported – Unsupported
DeviceInfo.Idiom correlates a constant string that maps to the type of device the application is running on. The values can be checked with the
- DeviceInfo.Idioms.Phone – Phone
- DeviceInfo.Idioms.Tablet – Tablet
- DeviceInfo.Idioms.Desktop – Desktop
- DeviceInfo.Idioms.TV – TV
- DeviceInfo.Idioms.Unsupported – Unsupported
DeviceInfo.DeviceType correlates an enumeration to determine if the application is running on a physical or virtual device. A virtual device is a simulator or emulator.
Platform Implementation Specifics
iOS does not expose an API for developers to get the name of the specific iOS device. Instead a hardware identifier is returned such as iPhone10,6 which refers to the iPhone X. A mapping of these identifers are not provided by Apple, but can be found on The iPhone Wiki (a non-official source source).