Is there a way I can do that with a Plugin or do I need to write some kind of a custom renderer?
Asked
Active
Viewed 5,025 times
4
-
Does this answer your question? [How to know the current OS / platform of the executing code (Android / iOS)](https://stackoverflow.com/questions/18570878/how-to-know-the-current-os-platform-of-the-executing-code-android-ios) – grooveplex Jan 12 '20 at 15:48
2 Answers
10
// Operating System Version Number (7.0)
var version = DeviceInfo.VersionString;
// Platform (Android)
var platform = DeviceInfo.Platform;

Jason
- 86,222
- 15
- 131
- 146
-
3If someone wants to compare versions this could be used `if (DeviceInfo.Version.Major >= 11) { // .... }` – testing Aug 27 '20 at 11:56
-
Official docs link : https://learn.microsoft.com/en-us/xamarin/essentials/device-information?tabs=ios – Mac Jan 22 '21 at 10:05
2
You could use Xam.Plugin.DeviceInfo
as well.
Xam.Plugin.DeviceInfo
: https://www.nuget.org/packages/Xam.Plugin.DeviceInfo
Code: In App.cs
// The root page of your application
MainPage = new ContentPage
{
Content = new StackLayout
{
Padding = 50,
VerticalOptions = LayoutOptions.Center,
Children = {
new Label{ Text = "Id: " + CrossDeviceInfo.Current.Id},
new Label{ Text = "Model: " + CrossDeviceInfo.Current.Model},
new Label{ Text = "Platform: " + CrossDeviceInfo.Current.Platform},
new Label{ Text = "Version: " + CrossDeviceInfo.Current.Version},
}
}
};
You could download the source code form the link for reference. https://github.com/jamesmontemagno/DeviceInfoPlugin

Wendy Zang - MSFT
- 10,509
- 1
- 7
- 17