dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22.01k stars 1.72k forks source link

Using Launcher in .NET MAUI to open a file opens the "share" menu on a Mac #14839

Open johnandrewoehler opened 1 year ago

johnandrewoehler commented 1 year ago

Description

When using the example provided in the documentationa "share" dialog opens up instead of the text file with default viewer (or open file extension dialog).

ydSOT

It does this with the exact code from the docs:

string popoverTitle = "Read text file";
string name = "File.txt";
string file = System.IO.Path.Combine(FileSystem.CacheDirectory, name);

System.IO.File.WriteAllText(file, "Hello World");

await Launcher.Default.OpenAsync(new OpenFileRequest(popoverTitle, new ReadOnlyFile(file)));

This is very similar to this issue for Xamarin.

Steps to Reproduce

  1. Clone the sample repo.
  2. Run it on a Mac.
  3. Click on the "Click me"
  4. Observe that it brings up the 'share' extensions menu and not the file or a menu to select which app to open it with (such as Previewer, Chrome, etc.)

Link to public reproduction project repository

https://github.com/johnandrewoehler/LauncherMacBugRepro

Version with bug

7.0 (current)

Last version that worked well

Unknown/Other

Affected platforms

macOS

Affected platform versions

macOS Ventura 13.3.1

Did you find any workaround?

https://github.com/xamarin/Essentials/issues/1877#issuecomment-1206154979

Relevant log output

No response

johnandrewoehler commented 1 year ago

This answer to this question on StackOverflow provides additional context:

https://stackoverflow.com/questions/76105845/using-launcher-in-net-maui-to-open-a-pdf-file-for-viewing/76133434#76133434

ghost commented 1 year ago

We've added this issue to our backlog, and we will work to address it as time and resources allow. If you have any additional information or questions about this issue, please leave a comment. For additional info about issue management, please read our Triage Process.

Gekidoku commented 1 year ago

Same issue on my iphone SE running ios 16.6

Gekidoku commented 10 months ago

Can we get a progress update on this? I have customers that have employees that cant view instructions that are included in a pdf file now.

Zhanglirong-Winnie commented 8 months ago

Verified this issue with VSMac 17.6.7. Can repro on maccatalyst with sample project. johnandrewoehler/LauncherMacBugRepro (github.com) image

willcorum commented 5 months ago

Any updates or workarounds?

infor-ajdragasa commented 2 months ago

Any update on this please? I'm getting the same issue when opening a simple JPG or PDF file. Still showing the same edit action window instead of opening the default app for the specific file. I already passed the MimeType.

Happning in iOS 17.2

image

FileInfo fi = new FileInfo(path);
var mimeType = MimeTypeHelper.GetMimeTypeFromExtension(fi.Extension);
return await Launcher.Default.OpenAsync(new OpenFileRequest
{
    File = new ReadOnlyFile(path, mimeType)
});
FabriBertani commented 1 month ago

Any update on this @PureWeen @jfversluis @samhouts ?