Skip to content

Commit

Permalink
feat(ios): expose RunEvent::Opened (#7440)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasfernog authored Jul 17, 2023
1 parent a5752db commit 753900d
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changes/run-event-opened.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"tauri": patch:feat
---

Expose `RunEvent::Opened` on macOS and iOS for deep link support.
2 changes: 1 addition & 1 deletion core/tauri-runtime-wry/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2952,7 +2952,7 @@ fn handle_event_loop<T: UserEvent>(
);
}
},
#[cfg(target_os = "macos")]
#[cfg(any(target_os = "macos", target_os = "ios"))]
Event::Opened { urls } => {
callback(RunEvent::Opened { urls });
}
Expand Down
2 changes: 1 addition & 1 deletion core/tauri-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ pub enum RunEvent<T: UserEvent> {
/// 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<url::Url> },
/// A custom event defined by the user.
UserEvent(T),
Expand Down
4 changes: 2 additions & 2 deletions core/tauri/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<url::Url>,
Expand Down Expand Up @@ -1523,7 +1523,7 @@ fn on_event_loop_event<R: Runtime, F: FnMut(&AppHandle<R>, 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!(),
};
Expand Down
2 changes: 1 addition & 1 deletion examples/file-associations/src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 753900d

Please sign in to comment.