Get Started with Xamarin.Essentials

Pre-release NuGet

Xamarin.Essentials provides a single cross-platform API that works with any iOS, Android, or UWP application that can be accessed from shared code no matter how the user interface is created.

Platform Support

Xamarin.Essentials supports the following platforms and operating systems:

Platform Version
Android 4.4 (API 19) or higher
iOS 10.0 or higher
UWP 10.0.6299.0 or higher

Installation

Xamarin.Essentials is available as a NuGet package that can be added to any existing or new project using Visual Studio.

  1. Download and install Visual Studio with the Visual Studio tools for Xamarin.

  2. Open an existing project, or create a new project using the Blank App template under Visual Studio C# (Android, iPhone & iPad, or Cross-Platform). Important: If adding to a UWP project ensure Build 16299 or higher is set in the project properties.

  3. Add the Xamarin.Essentials NuGet package to each project:

    In the Solution Explorer panel, right click on the solution name and select Manage NuGet Packages. Search for Xamarin.Essentials and install the package into ALL projects including Android, iOS, UWP, and .NET Standard libraries.

    Tip

    Check the Include prerelease box while the Xamarin.Essentials NuGet is in preview.

  4. Add a reference to Xamarin.Essentials in any C# class to reference the APIs.

    using Xamarin.Essentials;
    
  5. Xamarin.Essentials requires platform-specific setup:

    In the Android project's MainLauncher or any Activity that is launched Xamarin.Essentials must be initialized in the OnCreate method:

    Xamarin.Essentials.Platform.Init(this, bundle);
    

    To handle runtime permissions on Android, Xamarin.Essentials must receive any OnRequestPermissionsResult. Add the following code to all Activity classes:

    public override void OnRequestPermissionsResult(int requestCode, string[] permissions, [GeneratedEnum] Android.Content.PM.Permission[] grantResults)
    {
        Xamarin.Essentials.Platform.OnRequestPermissionsResult(requestCode, permissions, grantResults);
    
        base.OnRequestPermissionsResult(requestCode, permissions, grantResults);
    }
    
  6. Follow the Xamarin.Essentials guides that enable you to copy and paste code snippets for each feature.

Other Resources

We recommend developers new to Xamarin visit Getting Started with Xamarin Development.

Visit the Xamarin.Essentials GitHub Respository to see the current source code, what is coming next, run samples, and close the repository. Community contributions are welcome!

Browse through the API documentation for every feature of Xamarin.Essentials.