Xamarin.Essentials: Device Information

The DeviceInfo class provides information about the device the application is running on.

Get started

To start using this API, read the getting started guide for Xamarin.Essentials to ensure the library is properly installed and set up in your projects.

Using DeviceInfo

Add a reference to Xamarin.Essentials in your class:

using Xamarin.Essentials;

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;

Platforms

DeviceInfo.Platform correlates to a constant string that maps to the operating system. The values can be checked with the DevicePlatform struct:

  • DevicePlatform.iOS – iOS
  • DevicePlatform.Android – Android
  • DevicePlatform.UWP – UWP
  • DevicePlatform.Unknown – Unknown

Idioms

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 DeviceIdiom struct:

  • DeviceIdiom.Phone – Phone
  • DeviceIdiom.Tablet – Tablet
  • DeviceIdiom.Desktop – Desktop
  • DeviceIdiom.TV – TV
  • DeviceIdiom.Watch – Watch
  • DeviceIdiom.Unknown – Unknown

Device Type

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).

API