From 753900dd6e549aaf56f419144382669e3b246404 Mon Sep 17 00:00:00 2001 From: Lucas Fernandes Nogueira Date: Mon, 17 Jul 2023 15:44:34 -0700 Subject: [PATCH] feat(ios): expose `RunEvent::Opened` (#7440) --- .changes/run-event-opened.md | 5 +++++ core/tauri-runtime-wry/src/lib.rs | 2 +- core/tauri-runtime/src/lib.rs | 2 +- core/tauri/src/app.rs | 4 ++-- examples/file-associations/src-tauri/src/main.rs | 2 +- 5 files changed, 10 insertions(+), 5 deletions(-) create mode 100644 .changes/run-event-opened.md diff --git a/.changes/run-event-opened.md b/.changes/run-event-opened.md new file mode 100644 index 000000000000..99c845802c4d --- /dev/null +++ b/.changes/run-event-opened.md @@ -0,0 +1,5 @@ +--- +"tauri": patch:feat +--- + +Expose `RunEvent::Opened` on macOS and iOS for deep link support. diff --git a/core/tauri-runtime-wry/src/lib.rs b/core/tauri-runtime-wry/src/lib.rs index fe76a6244908..b8413c4a7571 100644 --- a/core/tauri-runtime-wry/src/lib.rs +++ b/core/tauri-runtime-wry/src/lib.rs @@ -2952,7 +2952,7 @@ fn handle_event_loop( ); } }, - #[cfg(target_os = "macos")] + #[cfg(any(target_os = "macos", target_os = "ios"))] Event::Opened { urls } => { callback(RunEvent::Opened { urls }); } diff --git a/core/tauri-runtime/src/lib.rs b/core/tauri-runtime/src/lib.rs index 403878bf8076..ea9d02916df2 100644 --- a/core/tauri-runtime/src/lib.rs +++ b/core/tauri-runtime/src/lib.rs @@ -315,7 +315,7 @@ pub enum RunEvent { /// This event is useful as a place to put your code that should be run after all state-changing events have been handled and you want to do stuff (updating state, performing calculations, etc) that happens as the “main body” of your event loop. MainEventsCleared, /// Emitted when the user wants to open the specified resource with the app. - #[cfg(target_os = "macos")] + #[cfg(any(target_os = "macos", target_os = "ios"))] Opened { urls: Vec }, /// A custom event defined by the user. UserEvent(T), diff --git a/core/tauri/src/app.rs b/core/tauri/src/app.rs index 72e8be0798d4..5a60719fa1a2 100644 --- a/core/tauri/src/app.rs +++ b/core/tauri/src/app.rs @@ -178,7 +178,7 @@ pub enum RunEvent { /// This event is useful as a place to put your code that should be run after all state-changing events have been handled and you want to do stuff (updating state, performing calculations, etc) that happens as the “main body” of your event loop. MainEventsCleared, /// Emitted when the user wants to open the specified resource with the app. - #[cfg(target_os = "macos")] + #[cfg(any(target_os = "macos", target_os = "ios"))] Opened { /// The URL of the resources that is being open. urls: Vec, @@ -1523,7 +1523,7 @@ fn on_event_loop_event, RunEvent) + 'static>( RuntimeRunEvent::Resumed => RunEvent::Resumed, RuntimeRunEvent::MainEventsCleared => RunEvent::MainEventsCleared, RuntimeRunEvent::UserEvent(t) => t.into(), - #[cfg(target_os = "macos")] + #[cfg(any(target_os = "macos", target_os = "ios"))] RuntimeRunEvent::Opened { urls } => RunEvent::Opened { urls }, _ => unimplemented!(), }; diff --git a/examples/file-associations/src-tauri/src/main.rs b/examples/file-associations/src-tauri/src/main.rs index b2e95a714932..3611d52fb043 100644 --- a/examples/file-associations/src-tauri/src/main.rs +++ b/examples/file-associations/src-tauri/src/main.rs @@ -52,7 +52,7 @@ fn main() { .build(tauri::generate_context!()) .expect("error while running tauri application") .run(|app, event| { - #[cfg(target_os = "macos")] + #[cfg(any(target_os = "macos", target_os = "ios"))] if let tauri::RunEvent::Opened { urls } = event { if let Some(w) = app.get_window("main") { let urls = urls