Skip to content
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

feat(deep-link): Add deep link support for desktop #916

Merged
merged 29 commits into from
May 9, 2024
Merged

Conversation

FabianLars
Copy link
Member

@sebasptsch
Copy link

This looks interesting, is this on hold for the moment whilst v2 is finalised?

@FabianLars
Copy link
Member Author

it was waiting for the beta release with the big allowlist/ACL changes, yes. Since then i was out sick so i couldn't work on this yet.

This week i've also talked with a community member about the url handling mess in the context of cross platform support (android, ios, macos have an explicit event and are single instance by default, while linux and windows spawn a new instance that gets the url as a cli arg), and i'm not sure how, or if at all to handle it yet, maybe it will be in a follow up pr idk.

@amrbashir
Copy link
Member

single-instance should not be handled by deep-link, it should be handled by the single-instance plugin

@FabianLars
Copy link
Member Author

FabianLars commented Feb 27, 2024

i did not forget about your stance on this topic :P And that's also not reallyyy what i meant, i agree that the deep link plugin shouldn't change this behavior.

I'll have to find the discussions again to remember what i actually meant though lol. We at least need more docs to show how to handle this, or at least stating the platform differences.

Anyway, no major changes are planned.

@pauliesnug
Copy link

pauliesnug commented Mar 23, 2024

@FabianLars is this plugin ready for release since deep-links was merged into tauri v2? i'd love macos/linux/windows support added to the current mobile plugin.

@FabianLars
Copy link
Member Author

not quite. If it's enough to register the schemes at install time, and not at runtime, then using the latest tauri cli already support that. The plugin only adds apis to un/register schemes at runtime.

@pauliesnug
Copy link

not quite. If it's enough to register the schemes at install time, and not at runtime, then using the latest tauri cli already support that. The plugin only adds apis to un/register schemes at runtime.

@FabianLars is there documentation on how to do desktop deep linking with the latest tauri cli?

@FabianLars
Copy link
Member Author

No, here's how to configure it: https://github.com/tauri-apps/plugins-workspace/pull/916/files#diff-98b5031760ba756df7078118e3724551064a6b92fe1537a0a19ca5daacdda748 (This already works as long as you don't need mobile and therefore don't include this plugin in your project)

You can get the invoked links on macOS like on iOS: https://beta.tauri.app/features/deep-linking/#usage

On Windows and Linux this will open a new instance with the url in the cli args (accessible in rust via std::env::args()). If you want to keep it single instance like on macos you need to use the single-instance plugin.

@FabianLars FabianLars marked this pull request as ready for review March 28, 2024 18:38
@CrabNejonas
Copy link

Yes. I honestly don't even want to think about how to get the timing for that right (it's basically the "how can i use emit in the setup hook" question). You can use getCurrent/get_current api on app start instead.

ohh okay thx thats a fine solution imo

@lucasfernog-crabnebula
Copy link
Contributor

I think it would be valuable to add a Rust event (maybe a closure) for the new-url event, currently it's tricky to get the URLs because the current value is filled after emitting the webview event.

@FabianLars
Copy link
Member Author

I'm a bit dense today, could you explain the issue differently somehow? 😅

@lucasfernog-crabnebula
Copy link
Contributor

nvm we can just document the new-url event payload format and users deserialize manually

@FabianLars
Copy link
Member Author

i didn't test the linux changes i just pushed but will mark this as ready for review already because yolo (rly tho please review it, and if you test the linux implementation for me that'd be even better 🙃)

assuming everything is correct, and we're happy with the UnsupportedPlatform error, the only thing left to do is adding desktop support to the example and adding the single-instance plugin to the readme as requested by Amr.

@FabianLars FabianLars marked this pull request as ready for review April 17, 2024 16:06
@FabianLars
Copy link
Member Author

probably a good idea to split it into multiple files per platform cause those cfg flags are urgh

@fax1ty
Copy link

fax1ty commented May 2, 2024

How to register a schema?
Like in v1

tauri_plugin_deep_link::register("custom-schema", move |request| {
   handle.emit_all("scheme-request-received", request).unwrap();
})

Is it not ready yet?

@FabianLars
Copy link
Member Author

You can do this: https://github.com/tauri-apps/plugins-workspace/pull/916/files#diff-98b5031760ba756df7078118e3724551064a6b92fe1537a0a19ca5daacdda748 to make the app register them on installation.

Or you use the good old register functions to register them at runtime, yes.
However, they won't accept a handler function anymore, but the plugin will instead emit an event on macos, ios and android and on windows and linux the url will be in std::env::args[1].
The single instance mechanism was also removed from the plugin so you'll have to use the separate single-instance plugin now (only windows and linux).

@fax1ty
Copy link

fax1ty commented May 2, 2024

@FabianLars Can I use it right now? Like so

tauri-plugin-deep-link = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "desktop-deep-links" }

I need to migrate Tauri v1 application to v2, but it uses the schema functionality

@amrbashir amrbashir merged commit 8121e90 into v2 May 9, 2024
138 checks passed
@amrbashir amrbashir deleted the desktop-deep-links branch May 9, 2024 16:58
@pauliesnug
Copy link

@FabianLars are there docs for this since its been merged now?

@FabianLars
Copy link
Member Author

@FabianLars are there docs for this since its been merged now?

No, i did not expect that this would get merged as-is (see my comments above), yet alone actually released, so i didn't work on docs. I can't give you an ETA on it right now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[deep-link] v2 - desktop support
9 participants