feat(ios): expose RunEvent::Opened (#7440)

This commit is contained in:
Lucas Fernandes Nogueira 2023-07-17 15:44:34 -07:00 committed by GitHub
parent a5752db985
commit 753900dd6e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 10 additions and 5 deletions

View File

@ -0,0 +1,5 @@
---
"tauri": patch:feat
---
Expose `RunEvent::Opened` on macOS and iOS for deep link support.

View File

@ -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 });
}

View File

@ -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),

View File

@ -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>,
@ -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!(),
};

View File

@ -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