tauri icon indicating copy to clipboard operation
tauri copied to clipboard

[feat] support for non-http protocols on Windows (and Android)

Open happybeing opened this issue 1 year ago • 3 comments

Describe the problem

I'm able to use custom protocols in my app when built for Linux, but on Windows I get the error:

"Failed to launch 'myprotocol://blah' because the scheme does not have a registered handler."

Describe the solution you'd like

I'm not absolutely sure this isn't a bug, or just something I don't know how to do, but what I want is...

  • the ability to implement a custom protocol handler (e.g. to handle URLs of the form myprotocol://something) on all platforms without the need to translate the URL 'manually' into a platform specific form (which on Windows I think would be http://myprotocol.something).

Alternatives considered

I understand from discussion on Discord that the Tauri core API convertFileSrc() can be used to translate before applying the URI, provided you have access to this programatically. However, I don't believe this is a solution because I am using an iframe to load content which has URLs embedded in it that may include the custom protocol, or may load other content that does so (e.g. if the user clicks a link). In those cases there's no way for me to translate the URLs programatically.

Additional context

I was told on the Discord that this issue should also apply to Android but I haven't confirmed this. However, some time ago I was trying an early version of my app in Android Studio emulator, and I thought that it had succeeded. I can't be sure though, and have found Android Studio unreliable so not easy for me to check.

The possibility that it was working on Android leads me to hope that there is though some way to do this without needing to use the convertFileSrc() or any other programmatic method, which is why I'm not sure if this is an existing feature or a feature request.

Unfortunately the Discord topic isn't resolving so I decided to open an issue so it won't get lost.

happybeing avatar Aug 18 '24 11:08 happybeing

Copy pasting what i wrote on discord:

We can only support custom schemes on Windows by dropping Windows 7/8 support which (sadly) isn't planned for tauri v2.

On Android i think it's simply not possible, at least according to iirc Lucas when he worked on the custom protocol implementation. Edit: From a short google search it seems to be possible to react to custom scheme requests but data transfer seems a bit tricky. Also there are issues like https://ionic.io/blog/capacitor-android-customscheme-issue-with-chrome-117

FabianLars avatar Aug 18 '24 13:08 FabianLars

Is there any issue with a progressive enhancement approach: support custom schemes where available (Win 10+), but not elsewhere (Windows 7/8)?

(Actually, how did mail programs on Windows 7 handle schemes like mailto? I'm surprised to hear it's not possible. There appear to be Stack Overflow questions about it dating back to the Windows 7 era, too, like this one.)

ConnorKrammer avatar Aug 20 '24 08:08 ConnorKrammer

Is there any issue with a progressive enhancement approach: support custom schemes where available (Win 10+), but not elsewhere (Windows 7/8)?

Ignoring our time constraints it would also make it annoying for users to not only care about platforms but also platform versions. Also we did not extensively try the new-ish custom protocol support in webview2 yet so we don't know if it even works for us etc

(Actually, how did mail programs on Windows 7 handle schemes like mailto? I'm surprised to hear it's not possible. Hm.)

That's something completely different. I'd say mailto counts to "deep links" while we're talking about a webview internal method to register new http/s like schemes for the webview to handle (not the OS): https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2customschemeregistration?view=webview2-1.0.2651.64 This has nothing to do with the OS itself, it just happens to know that the webview2 method was added in v110 and v119 while v109 is the last version that works on win7.

FabianLars avatar Aug 20 '24 09:08 FabianLars

The discussion so far is about Windows, but what about Android targets? Is there a way to make it work there?

SolidTux avatar Nov 14 '24 19:11 SolidTux

my first comment included something about android.

FabianLars avatar Nov 14 '24 20:11 FabianLars