# `Dala.Platform.Linking`
[🔗](https://github.com/manhvu/dala/blob/main/lib/dala/platform/linking.ex#L1)

Linking API for opening URLs and handling deep links.

## Examples

    # Open an external URL
    socket = Dala.Platform.Linking.open_url(socket, "https://example.com")

    # Check if a URL can be opened
    Dala.Platform.Linking.can_open?("https://example.com") #=> true | false

    # Get the initial URL that launched the app
    Dala.Platform.Linking.initial_url() #=> nil | "https://..."

Incoming deep link messages are delivered to screens via `handle_info/2`:

    def handle_info({:linking, :url, url}, socket) do
      # Process deep link URL
      {:noreply, socket}
    end

# `can_open?`

```elixir
@spec can_open?(String.t()) :: boolean()
```

Check if a URL can be opened by any installed app.

Returns `true` if the URL scheme is handled, `false` otherwise.

# `initial_url`

```elixir
@spec initial_url() :: String.t() | nil
```

Get the URL that launched the app (deep link), if any.

Returns the URL string or `nil` if the app was not launched via a URL.

# `open_url`

```elixir
@spec open_url(Dala.Socket.t(), String.t()) :: Dala.Socket.t()
```

Open an external URL in the system browser or appropriate app.

Returns the socket unchanged.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
