[FIXED] How to detect iOS device type Xamarin

Issue

I want to detect first what is the platform and the I want to detect is whether it is a phone or tablet.
I searched on the internet there are many examples to detect with screen size like height-width, but is there anything which can let what is the device type.

if(Device.RuntimePlatform == Device.iOS)
{
    //what is the device type 
}
else if(Device.RuntimePlatform == Device.Android)
{
    //what is the device type
}

Solution

Use this to detect device type.


if(Device.RuntimePlatform == Device.iOS)
{
    //what is the device type
   if (Device.Idiom == TargetIdiom.Phone)
   {
       Console.WriteLine(Device.Idiom);
   }
   else if(Device.Idiom == TargetIdiom.Tablet)
   {
       Console.WriteLine(Device.Idiom);
   } 

}
else if(Device.RuntimePlatform == Device.Android)
{
    //what is the device type
}

Answered By – TheHunter Shergill

Answer Checked By – Timothy Miller (Easybugfix Admin)

Leave a Reply

(*) Required, Your email will not be published