Xamarin.Essentials 1.6 release notes

Getting Started | What's New | Breaking Changes | Blogs | Thank you | Feedback | Open Source

What's New in this Release

macOS Support

You can now install and use Xamarin.Essentials in macOS applications. Supported versions of macOS are macOS Sierra (10.12.6) and higher. See the platform support documentation to see what features are supported.

App Actions

Create and react to shortcuts from the applications icon.

try
{
    await AppActions.SetAsync(
        new AppAction("app_info", "App Info", icon: "app_info_action_icon"),
        new AppAction("battery_info", "Battery Info"));
}
catch (FeatureNotSupportedException ex)
{
    Debug.WriteLine("App Actions not supported");
}

Contacts

The Contacts class lets a user pick a contact and retrieve information about it or get all list of contacts from the user's device.

try
{
    var contact = await Contacts.PickContactAsync();

    if(contact == null)
        return;

    var id = contact.Id;
    var namePrefix = contact.NamePrefix;
    var givenName = contact.GivenName;
    var middleName = contact.MiddleName;
    var familyName = contact.FamilyName;
    var nameSuffix = contact.NameSuffix;
    var displayName = contact.DisplayName;
    var phones = contact.Phones; // List of phone numbers
    var emails = contact.Emails; // List of email addresses
}
catch (Exception ex)
{
    // Handle exception here.
}

File Picker

The FilePicker API allows users to select a single or multiple files from the document browser. This includes generic documents or media content and this can be filtered down by PickOptions that are specified when calling any of the methods.

async Task<FileResult> PickAndShow(PickOptions options)
{
    try
    {
        var result = await FilePicker.PickAsync();
        if (result != null)
        {
            Text = $"File Name: {result.FileName}";
            if (result.FileName.EndsWith(".jpg", StringComparison.OrdinalIgnoreCase) ||
                result.FileName.EndsWith(".png", StringComparison.OrdinalIgnoreCase))
            {
                var stream = await result.OpenReadAsync();
                Image = ImageSource.FromStream(() => stream);
            }
        }
    }
    catch (Exception ex)
    {
        // The user canceled or something went wrong
    }
}

Haptic Feedback

The Haptic Feedback functionality can be performed with a Click or LongPress feedback type to vibrate the device.

try
{
    // Perform click feedback
    HapticFeedback.Perform(HapticFeedbackType.Click);

    // Or use long press    
    HapticFeedback.Perform(HapticFeedbackType.LongPress);
}
catch (FeatureNotSupportedException ex)
{
    // Feature not supported on device
}
catch (Exception ex)
{
    // Other error has occurred.
}

Media Picker

The MediaPicker allows the following operations.

  • PickPhotoAsync: Opens the media browser to select a photo.
  • CapturePhotoAsync: Opens the camera to take a photo.
  • PickVideoAsync: Opens the media browser to select a video.
  • CaptureVideoAsync: Opens the camera to take a video.
async Task TakePhotoAsync()
{
    try
    {
        var photo = await MediaPicker.CapturePhotoAsync();
        await LoadPhotoAsync(photo);

        Console.WriteLine($"CapturePhotoAsync COMPLETED: {PhotoPath}");
    }
    catch (Exception ex)
    {
        Console.WriteLine($"CapturePhotoAsync THREW: {ex.Message}");
    }
}

Screenshot

The Screenshot class lets take a capture of the current displayed screen of the app.

async Task CaptureScreenshot()
{
    var screenshot = await Screenshot.CaptureAsync();
    var stream = await screenshot.OpenReadAsync();

    Image = ImageSource.FromStream(() => stream);
}

Share Multiple Files

The Share.RequestAsync method now allows users to send multiple files.

var file1 = Path.Combine(FileSystem.CacheDirectory, "Attachment1.txt");
File.WriteAllText(file, "Content 1");
var file2 = Path.Combine(FileSystem.CacheDirectory, "Attachment2.txt");
File.WriteAllText(file, "Content 2");

await Share.RequestAsync(new ShareMultipleFilesRequest
{
    Title = ShareFilesTitle,
    Files = new ShareFile[] { new ShareFile(file1), new ShareFile(file2) }
});

Other Features

Release History

  • Thursday, January 21, 2020 - Xamarin.Essentials 1.6.1-preview2
  • Sunday, December 27, 2020 - Xamarin.Essentials 1.6.1-preview1
  • Tuesday, December 22, 2020 - Xamarin.Essentials 1.6.0
  • Saturday, December 12, 2020 - Xamarin.Essentials 1.6.0-rc1
  • Sunday, December 6, 2020 - Xamarin.Essentials 1.6.0-pre5
  • Tuesday, November 13, 2020 - Xamarin.Essentials 1.6.0-pre4
  • Friday, November 6, 2020 - Xamarin.Essentials 1.6.0-pre3
  • Friday, September 25, 2020 - Xamarin.Essentials 1.6.0-pre2
  • Tuesday, September 15, 2020 - Xamarin.Essentials 1.6.0-pre1

Xamarin.Essentials 1.6.0

Issues Fixed

  • GH-1358 Fix WebAuthenticator on UWP from throwing FileNotFoundException
  • GH-1354 Null checks on Android's file provider
  • GH-1296 Fix iOS leak on WebAuthenticator
  • GH-1319 Fix iOS speakback not stopping on cancel
  • And more

Xamarin.Essentials 1.6.1 (preview)

Issues Fixed

  • GH-1559 Changes to display of contacts list in Contact picker for Android
  • GH-1613 Fix incorrect detection of WiFi on iOS
  • GH-1622 Fix TextToSpeech's incorrect Locale objects on macOS
  • GH-1649 Make sure to require permissions for FilePicker

API Changes

  • GH-1637 Added the ability to set the location of the Launcher popup on iPads
  • GH-1443 Add new property DisplayInfo.RefreshRate

Breaking Changes

  • None

Blogs

Xamarin Blogs

Thank you

Thank you to our community for helping to make Xamarin.Essentials even better!

This release, we received amazing contributions from these individuals:

Give them a big round of applause!

Feedback

Your feedback is important to us. If you encounter problems with Xamarin.Essentials, check the Xamarin Forums and Xamarin.Forms GitHub for existing issues. Report new issues and suggestions on GitHub.

Open Source

Xamarin.Essentials 1.6.0 is based on the open-source Xamarin.Essentials repository: