open

actual fun open(url: String)

Opens the specified URL in Chrome Custom Tabs.

This method launches Chrome Custom Tabs with the provided URL. If Custom Tabs are not available, it falls back to the default browser application.

Behavior

  • Parses the URL using Android's Uri.parse()

  • Creates a CustomTabsIntent with default configuration

  • Launches the Custom Tab from the initialized Activity

  • Logs errors without crashing the app if something goes wrong

Error Handling

  • Throws IllegalStateException if not initialized

  • Logs parsing or launching errors without crashing

  • Gracefully handles malformed URLs

Parameters

url

The URL to open in Custom Tabs

See also

Throws

if init has not been called or if the Activity reference is no longer valid (e.g., Activity destroyed)

expect fun open(url: String)

Opens the specified URL in the platform's native in-app browser.

This method launches the appropriate in-app browser for each platform:

  • Android: Opens URL in Chrome Custom Tabs with the default browser styling

  • iOS: Opens URL in SFSafariViewController with Safari's security features

Parameters

url

The URL to open.

Throws

on Android if KInAppBrowser not initialized or if the Activity reference is no longer valid

actual fun open(url: String)

Opens the specified URL in SFSafariViewController or system browser.

This method automatically determines the best way to open the URL:

  • HTTP/HTTPS URLs: Opens in SFSafariViewController for in-app browsing

  • Other schemes: Opens with UIApplication for system handling

Behavior

  • Automatically finds the top-most view controller for presentation

  • Presents SFSafariViewController with smooth animations

  • Maintains reference for programmatic dismissal

  • Falls back to system browser for non-HTTP(S) URLs

  • Logs errors without crashing the app

Error Handling

  • Gracefully handles malformed URLs

  • Logs errors using NSLog for debugging

  • Continues execution even if URL opening fails

Parameters

url

The URL to open. Can be any valid URL scheme. HTTP/HTTPS URLs will open in SFSafariViewController, other schemes will be handled by the system.

See also