Dala.Platform.Linking (dala v0.3.2)

Copy Markdown View Source

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

Summary

Functions

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

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

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

Functions

can_open?(url)

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

@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(socket, url)

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