socketsupply / socket

A cross-platform runtime for Web developers to build desktop & mobile apps for any OS using any frontend library.
https://socketsupply.co/guides
Other
1.6k stars 75 forks source link

onApplicationURL hook does not run when app is in a closed state #988

Open daniel-le97 opened 1 month ago

daniel-le97 commented 1 month ago

What OS are you using (uname -a, or Windows version)?

Darwin Daniels-MacBook-Air.local 23.5.0 Darwin Kernel Version 23.5.0: Wed May 1 20:16:51 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T8103 arm64

What version Socket Runtime are you using?

0.5.4 (dfd41903) Installation path: /Users/daniel/homelab/GitHub/languages/javascript/socket/build/npm/darwin/packages/@socketsupply/socket-darwin-arm64/ ( next branch)

What programming language are you using (C/C++/Go/Rust)?

none

What did you expect to see and what you saw instead?

For internal and external linking, I am using the following code snippet to capture the URL when the app is already open:

import { onApplicationURL } from "socket:hooks";

onApplicationURL((event: ApplicationURLEvent) => {
  console.log(event.url); // logs myapp://some-path
  console.log({ event });
});

When the app is already open, the onApplicationURL event fires correctly, and I can capture the URL. However, if the app is not open and a deep link is clicked, the event does not run once the app is opened.

Steps to Reproduce:

  1. Ensure an application protocol is set in meta.application_protocol in socket.ini (e.g. myapp)
    1. Ensure the app is completely closed (no windows open).
    2. Click a deep link that should open the app (e.g., myapp://some-path).
    3. Observe that the app opens, but the onApplicationURL event does not fire.