XPlat Windows APIs version 1.4 is now available in the wild as NuGet packages for you to download to your applications or you can get the source via GitHub!

XPlat Windows APIs

What is XPlat?

XPlat Windows APIs is an open-source project that was created as a result of a need to port a rather large application from the Universal Windows Platform (UWP) to Android using Xamarin.

Given the already existing code in the application, the solution we needed to provide was for the least code change to ensure the application could be back up and running as soon as possible.

The result is XPlat Windows APIs, a collection of cross-platform APIs designed to ease development of Xamarin applications with Windows-like APIs.

A good example of this is the Windows StorageFile. XPlat has a universal API for StorageFile which follows a near perfect mirror of properties and methods for both Android and iOS applications.

What’s new?

Update 1.4’s biggest change sees the code base migrated from portable class libraries (PCL) to .NET Standard.

.NET Standard & Multi-Targeting

One of the handiest features that was taken advantage of in the migration was multi-targeting providing the ability to create one project which creates a single NuGet package targeting .NET Standard 1.4, UWP, Xamarin.Android and Xamarin.iOS.

I have to thank Oren Novotny and his incredible MSBuildSdkExtras NuGet package which provides support for additional target frameworks such as uap, xamarin.android and xamarin.ios! You can take a look at the XPlat.Storage csproj file to see how this works in action!

API documentation

As part of this release, I’ve been working on methods to deliver documentation to you as a developer so you can take advantage of everything that’s to offer from XPlat.

The decision made was to use GitBook to surface this information and you can dive in at XPlat Windows APIs docs there!

The documentation is a work in progress and is still incomplete but I’m working to get this done as soon as possible. If you’d like to help out with our docs, you can fork our docs on GitHub!

API changes

There has also been some changes in the APIs in this release. 

The XPlat.Device.Launcher API is no longer static and has an interface implementation. This will help to keep this inline across platforms and provides better support for dependency injection in cross-platform apps. This also sees the implementation of the Launcher for Windows, providing a layer on top of the existing Windows Launcher API.

A RequestCodeHelper has been added to help generate request codes for Android applications that have a need for them, such as firing intents for results or handling permission requests.

The StorageFile and StorageFolder APIs now have a new Properties property which exposes the property metadata information of the items.

What’s been fixed?

There are also bug fixes as part of this release.

The CameraCaptureUI API for Android will now report when the user has denied permissions for accessing the camera so the application can support additional functions such as informing the user they require permission to launch it.

The Launcher API for Android now launches internally stored files (StorageFile) with external applications if configured correctly using the FileProvider in the application’s manifest.

The CoreDispatcher API for Windows will no longer lock up when attempting to run an action when the dispatcher already has thread access.

What’s next for XPlat?

XPlat is an open-source project and is always looking for community contributors to help out, whether that’s improving the docs, providing code for missing APIs or just testing/raising issues!

If you’re interested in helping out, take a look at XPlat Windows APIs on GitHub!

Join the discussion One Comment

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.