-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: Custom URI scheme support (deep linking) #323
Comments
The same goes for the "redirect uri" when authenticating with some external provider that uses Oauth (Auth0 for example). |
It'd be nice if there could be something similar to Electron's protocol API which lets you:
Regarding the protocol handlers, this is something that would need to be done in the webview dependency. |
In the dev branch of Tauri, we already use custom protocols to load web assets (See tauri-apps/wry#65). However, you can't create your own, is this a feature that would be useful? |
@nklayman It'd be super useful for me! I'm working on a p2p web browser called Agregore which uses Electron's protocol handlers to support loading content from p2p protocols like I like electron, but it'd be nice to be able to go closer to the metal and ditch all the JavaScript that's on the backend and use Rust. 😁 |
The other thing which I think is missing in a lot of webview libraries is the registerScemesAsPriviledged API that Electron provides. This is what lets custom protocol handlers to access APIs which are normally only available via HTTPs as well as make the URL parser treat them as "proper" URLs so that they can get a correct |
As a matter of fact, this is what wry is actually doing with its custom scheme @RangerMauve see: |
Oh wow! That's really cool to see @nothingismagick It'd be super handy if wry provided APIs to register different protocol schemes like that. |
#1553 is related to some of what has been discussed here (although that's not related to the original issue, which is just about deeplink support). |
Hello, I want to know how this function is progressing. |
+1 or could someone show an example on how to use it? |
The work on this feature is frozen because we're focusing on bug fixes ahead of a stable release and our audit. |
@lucasfernog Thanks for the update! Is this something you'll be able to continue on after the release/audit? |
Yeah hopefully I can get back to it after the release. |
Sweet, I'm excited to see how it progresses. 😁 This functionality can enable a lot of interesting use cases (especially for people making experimental browsers like myself). |
@lucasfernog Sorry to push you on this but its a feature we need it ASAP for us to use with oath. Also please consider how to communicate the change in deeplink to sidecar |
@hellomocks - we are currently in a feature freeze while the audit is ongoing and have some important revision work to do, so as Lucas said, this is not something that the core team will be getting to before the end of September. |
I would add, the custom URI support is handled by the registry keys on Windows and on macOS it's handled by a custom PLIST; something like this may work;
Tauri supports custom |
The initial poster mentioned implementing this via the Are you aware of a way to intercept the triggers or to redirect the invocation to an existing window instead of opening a second instance? |
This can be achieved with WIX but currently don't understand how to get the context replacement working with fragments. However, the wix settings allow you to override the default template which can be modified to achieve this effort.
I placed this component in the
section of the default WIX template (https://github.com/tauri-apps/tauri/blob/b0a8c38a736544cdd70fd10155e5ad3a25c81535/tooling/bundler/src/bundle/windows/templates/main.wxs) Then I updated my
This will create the registry keys under My list of items to continue investigating:
|
has there been any updates on this and if there are, is there an example? |
@RiChrisMurphy No, otherwise it would be listed or linked here... |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@FabianLars Been using the plugin on Windows 10/11 for a few months now, and it's been working flawlessly. Attempting to port to Mac at the moment - could you clarify what changes need to be made to the Tauri config? I'm just running the generated default config, but it's not registering the scheme in development + release mode. AFAIK there isn't a way to register deep links in develop mode, right? |
Correct, there used to be deprecated apis for that but they stopped working in the latest macos versions so i didn't even bother adding them. Basically you need to completely build the app (either p.s. once you have an app installed you can use Soooo, the tldr is:
Edit: One thing i forgot, the |
FYI there's some caveats about what programs are allowed to take focus on Windows. Normally when implementing single instance deep linking you call Chromium works around this by sending a dummy key press event, which lets @FabianLars 's tauri-plugin-deep-link works pretty well when launching via Start -> Run, but was suffering from the same focus issue when launched from a Windows Notification. It may be that implementing a Chrome-style workaround is what's required for that scenario. The workaround functioned perfectly for me in Electron. |
@RandomEngy This sounds like a general issue not just related to custom schemes, right? If so please open a separate issue for this! (preferably with a minimal reproduction app) p.s. does tauri's |
This issue happens when a second instance is launched from Windows Notifications. A protocol launch is one way for this to happen. I brought it up here because any implementation that tries to activate the primary app instance should be aware of this. I'll get together a small repro app using tauri-plugin-deep-link that demonstrates this. But I wouldn't say it's a bug on Tauri itself right now; there's no built-in feature that tries to activate a primary instance from a secondary one. The call to
Expected result: Actual result: |
Filed FabianLars/tauri-plugin-deep-link#26 with a minimal repro repository. |
@FabianLars Hi, I'm using also, the url scheme could launch the app, but seems cannot focus the app if already launched (the listeners gets called, just the window does not get focused), is it an unsolved issue? |
This is expected behavior. There is a comment and a small example in the repo example showing how to read the url if the primary instance was started via the scheme.
That kinda depends on your code i think, you may have to call window.set_focus() (should also work in js), if that doesn't work, please open an issue at my repo and we'll take a look. |
Thanks for the helpful guidance, I did miss the comment under example code, however the listeners still don't get invoked after putting the code in. The I have fired an new issue at the deep link repo, hope you could easily reproduce it. |
@FabianLars So it seems that deep linking on different OS comes with different set of problems.. Do you know whether deep linking for Tauri Mobile will come with an extra set of complications? |
The link handling on iOS seems to be covered by the macos implementation already. Registering the links are similar but doesn't re-use the same plist file (since it's not an .app bundle) afaik. The android implementation looks like it can't reuse anything. I don't know how hard that will be since I didn't really look into it yet but I'd imagine it also has some annoying quirks like all the other platforms. (P.S. either way I'm happy that I don't have to handle that in the plugin :D ) |
How you bypass this,please? |
on macOS, you can use |
This comment was marked as off-topic.
This comment was marked as off-topic.
After spending some time trying to figure out why The way the plugin gathers the URLs is through registering a handler on NSAppleEventManager . This is the OLD way. The new way is to use application:getURLS. And interestingly enough, this is what TAO already does (starting with this commit), but from what I understand not all TAO events are available in Tauri. What I discovered from a random person on the internet is that once you register the event handler (the old way) the method on the delegate (the new way) will not be called anymore. Which led me to an idea, that maybe the NSAppleEventManager was being called too early. I added an arbitrary 5 second delay before registering the event handler and it worked (and unsurprisingly, judgning from the lack of the relevant All of this leads me to a conclusion that for Tauri v2, the best way to implement custom scheme support on Mac OS is to propagate the event triggered by getURLs all the way to Tauri and use it instead of the NSAppleEventHandler. Hope my discovery session aids someone. |
Custom URL schemes provide a way to reference resources inside an app. Users tapping a custom URL e.g.
yourapp://foo?bar
in an email, for example, launch the app in a specified context. Other apps can also trigger the app to launch with specific context data; for example, a photo library app might display a specified image.Tauri could have a simplified API to register/unregister the custom URI scheme protocol a listener.
A Rust package https://github.com/maidsafe/system_uri exists that does System App URI registration for macOS, Linux and Windows. Unfortunately, this package does not support passing also the url params to the application - it only triggers the application launch. An example implementation together with Tauri -https://github.com/iotaledger/spark-wallet/blob/master/src-tauri/src/main.rs
The text was updated successfully, but these errors were encountered: