Xamarin.Essentials 1.7 and introducing .NET MAUI Essentials

James

Xamarin.Essentials has become a critical library for .NET developers building apps across iOS, Android, Tizen, macOS, and Windows since its original release over three years ago. Since then the library has been installed nearly 10 million times, has 79 contributors, has been stared 1,400 times on GitHub, and has been the foundation for developers around the globe to access native APIs. Today, I would like to share with you what is new in the latest version of Xamarin.Essentials 1.7, and talk about the future roadmap for the library as .NET Multi-platform App UI (MAUI) approaches this fall.

Xamarin.Essentials 1.7

This release of Xamarin.Essentials focuses on critical bug fixes and introduces enhancements to the Web Authenticator API.

Logo for Xamarin.Essentials

Web Authenticator

The Web Authenticator enables you to add authentication to your app and integrate with many providers using your own server backend powered by ASP.NET Core. There have been several fixes introduced for all platforms from the team and the community! Thank you!

Web authenticator overview of authentication from mobile to backend

We have also introduced a new API for private authentication sessions on iOS.

Private authentication session

iOS 13 introduced a new web browser API for developers to launch the authentication session as private. This enables developers to request that no shared cookies or browsing data is available between authentication sessions and will be a fresh login session each time. This is available through the new WebAuthenticatorOptions that was introduced in Xamarin.Essentials 1.7 for iOS.

var url = new Uri("https://mysite.com/mobileauth/Microsoft");
var callbackUrl = new Uri("myapp://")
var authResult = await WebAuthenticator.AuthenticateAsync(new WebAuthenticatorOptions
    {
        Url = url,
        CallbackUrl = callbackUrl,
        PrefersEphemeralWebBrowserSession = true
    });

.NET MAUI Essentials

.NET MAUI is the future of Xamarin.Forms and .NET MAUI Essentials is the future of Xamarin.Essentials. .NET MAUI Essentials is part of the .NET MAUI GitHub repo and has been under active development to seamlessly transition to .NET MAUI.

.NET MAUI Essentials is now directly integrated into .NET MAUI starting with .NET 6 Preview 6 and .NET MAUI Preview 6. When you create a new .NET MAUI application, it will use the new .NET MAUI workload and you will see <UseMaui>true</UseMaui> in the .csproj. With this enabled all of .NET MAUI Essentials comes into your project! All you need to do is add using Microsoft.Maui.Essentials; and all of the APIs you know and love are at your fingertips.

We know that there are developers today that will be updating their existing Xamarin.iOS and Xamarin.Android apps to .NET 6 without .NET MAUI and still want to leverage all of the APIs in Xamarin.Essentials. We have you covered as well as you can add <UsingMauiEssentials>true</UsingMauiEssentials> to your .NET 6 iOS and Android apps to bring in all of the latest APIs.

We are excited for this next chapter of Xamarin.Essentials with .NET MAUI Essentials and we hope you are too!

Sunsetting Xamarin.Essentials

Earlier this year we announced that we will be following the same schedule as Xamarin.Forms. This means that we will continue to service Xamarin.Essentials through November 2022 and accept pull requests fixing bugs and publishing new service releases. New features and APIs will only be added to .NET MAUI Essentials going forward and pull-requests are welcome!

Summary

Please let us know about your experiences using .NET MAUI Essentials in .NET MAUI Preview 6 to create new applications by engaging with us on GitHub at dotnet/maui.

For a look at what is coming in future releases, visit the .NET MAUI product roadmap.

5 comments

Comments are closed. Login to edit/delete your existing comments

  • Anton Christiansen

    Why did you call it Maui essentials? It has nothing to do with UI?? It should be called Microsoft.Essentials or something like that. We are a lot of people who don’t want MAUI and just want android and iOS with .net 6.

  • Johan Mulder

    Hi James, indeed an awesome library. I think the most used class in Essentials must be Preferences .

    Please make preferences also work cross platform in Blazor !!! If I use Preferences.Set(“my_key”, “my_value”) in blazor it does not work so I end rewriting huge amount of code for Blazor.

  • Максим Кошевой

    Glad to see things are moving forward! Already trying to migrate my app to MAUI.

    You have a typo there. Correct tag is UseMauiEssentials instead of UsingMauiEssentials.

    Also I have a project that targets .net6 (without -android) and build with UseMauiEssentials fails with

    NU1101 Unable to find package Microsoft.Maui.Essentials.Ref.. No packages exist with this id in source(s): ...

    It expects -android in target framework, but this is a platform-agnostic library that is later included in project that targets android.

    Here’re some things that it uses from Xamarin/MAUI nugets that are not platform specific:
    – Essentials: Preferences
    – Graphics: Color/Colors
    – Controls: MessagingCenter, IValueConverter, IMarkupExtension, BindingBase, BindableObject and similar

    Is there some way to still use them without targeting android and/or ios in all projects?

  • Paul Wolf

    I wrote a simple Maui Blazor app and am using Microsoft.Maui.Essentials. The app crashs with a “Window Not Found” exception when I call:

       
        var photo = await MediaPicker.CapturePhotoAsync();
    

    I’m using the Android emulator and in the startup in the Configure() call, I initialize Platform:

       
       #if __ANDROID__
                Microsoft.Maui.Essentials.Platform.Init(MauiApplication.Current);
       #endif
    

    The output following the call is:
    [monodroid] MonodroidRuntime::monodroid_pinvoke_override (“java-interop”, “java_interop_jnienv_get_object_field”)
    [monodroid] Found java-interop@java_interop_jnienv_get_object_field in internal p/invoke map (0xd329a800)
    [monodroid] MonodroidRuntime::monodroid_pinvoke_override (“java-interop”, “java_interop_jnienv_get_object_field”)
    [monodroid] Found java-interop@java_interop_jnienv_get_object_field in internal p/invoke map (0xd329a800)
    [monodroid] MonodroidRuntime::monodroid_pinvoke_override (“java-interop”, “java_interop_jnienv_get_object_field”)
    [monodroid] Found java-interop@java_interop_jnienv_get_object_field in internal p/invoke map (0xd329a800)
    [Choreographer] Skipped 486 frames! The application may be doing too much work on its main thread.
    [eglCodecCommon] setVertexArrayObject: set vao to 1 (1) 0 0
    System.InvalidOperationException: ‘Window Not Found’

    [eglCodecCommon] glUtilsParamSize: unknow param 0x000085b5
    [eglCodecCommon] glUtilsParamSize: unknow param 0x000085b5
    [eglCodecCommon] setVertexArrayObject: set vao to 0 (0) 0 0
    [eglCodecCommon] setVertexArrayObject: set vao to 1 (1) 0 0
    [eglCodecCommon] setVertexArrayObject: set vao to 0 (0) 5 0
    [OpenGLRenderer] Davey! duration=8157ms; Flags=0, IntendedVsync=51704374895139, Vsync=51712474894815, OldestInputEvent=9223372036854775807, NewestInputEvent=0, HandleInputStart=51712483168900, AnimationStart=51712483208600, PerformTraversalsStart=51712484912400, DrawStart=51712485088900, SyncQueued=51712485518600, SyncStart=51712486002600, IssueDrawCommandsStart=51712486266700, SwapBuffers=51712531246400, FrameCompleted=51712532879800, DequeueBufferDuration=204000, QueueBufferDuration=429000,
    [eglCodecCommon] setVertexArrayObject: set vao to 2 (2) 0 0

    It seems odd to see:
    [Choreographer] Skipped 486 frames! The application may be doing too much work on its main thread.

  • Ashish Shrivastav

    Hi,Can we convert xamarin forms and Essentials version – SDK 11.2.2.1 controls to Maui.Please let us know if there is any way to do it.