Browse Source

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

Lucas Fernandes Nogueira 2 years ago
parent
commit
753900dd6e

+ 5 - 0
.changes/run-event-opened.md

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

+ 1 - 1
core/tauri-runtime-wry/src/lib.rs

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

+ 1 - 1
core/tauri-runtime/src/lib.rs

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

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

+ 1 - 1
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