xamarin / Essentials

Xamarin.Essentials is no longer supported. Migrate your apps to .NET MAUI, which includes Maui.Essentials.
https://aka.ms/xamarin-upgrade
Other
1.52k stars 505 forks source link

[Bug] Launcher Feature does not open file correctly on IOS. #2027

Open snufffgit opened 2 years ago

snufffgit commented 2 years ago

Description

Launcher Feature does not open file correctly on IOS.

Scenario 1:

I can reproduce this error in your sample application.

await Launcher.OpenAsync(new OpenFileRequest { File = new ReadOnlyFile(file), PresentationSourceBounds = rect });

Scenario 2:

await Launcher.OpenAsync(new OpenFileRequest { File = new ReadOnlyFile(FullPath, System.Net.Mime.MediaTypeNames.Application.Pdf) });

Steps to Reproduce

Scenario 1:

  1. Open Xamarin.Essentials sample application.
  2. Go to Launcher sample
  3. Type some text on File Contents
  4. Click on Open File button.

Scenario 2:

  1. Get a pdf path.
  2. Execute Scenario 2 code: Launcher.OpenAsync with ReadOnlyFile(FullPath, System.Net.Mime.MediaTypeNames.Application.Pdf) overload.

Expected Behavior

Scenario 2:

image

Actual Behavior

Scenario 1:

Application throws an unhandled exception as follows: System.ArgumentNullException has been thrown Value cannot be null. Parameter name:uti

Scenario 2:

image

Basic Information

tilemmpon commented 2 years ago

This seems related to https://github.com/xamarin/Essentials/issues/1877. Please check if the workaround I found https://github.com/xamarin/Essentials/issues/1877#issuecomment-1206154979 works for you.

snufffgit commented 2 years ago

This seems related to #1877. Please check if the workaround I found #1877 (comment) works for you.

That was the 2 Scenario, even when using second parameter, the behaviour should be open the document, not the edit actions middle screen .

tilemmpon commented 1 year ago

Indeed I understand. Xamarin is in security support since MAUI is out now so I assume these bugs will not be addressed anymore. I would suggest to either move to MAUI or if not possible use a workaround (for example I open PDFs in iOS via the browser).