feat(deep-link): add on_open_url Rust API (#1780)

This commit is contained in:
Lucas Fernandes Nogueira
2024-09-14 21:35:31 -03:00
committed by GitHub
parent 79d6e19c4b
commit 6f3f66794a
3 changed files with 75 additions and 15 deletions
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
use tauri::Listener;
use tauri_plugin_deep_link::DeepLinkExt;
// Learn more about Tauri commands at https://tauri.app/v1/guides/features/command
#[tauri::command]
@@ -33,16 +33,14 @@ pub fn run() {
// ensure deep links are registered on the system
// this is useful because AppImages requires additional setup to be available in the system
// and calling register() makes the deep links immediately available - without any user input
#[cfg(target_os = "linux")]
{
use tauri_plugin_deep_link::DeepLinkExt;
// additionally, we manually register on Windows on debug builds for development
#[cfg(any(target_os = "linux", all(debug_assertions, windows)))]
app.deep_link().register_all()?;
app.deep_link().register_all()?;
}
app.listen("deep-link://new-url", |url| {
dbg!(url);
app.deep_link().on_open_url(|event| {
dbg!(event.urls());
});
Ok(())
})
.invoke_handler(tauri::generate_handler![greet])