KInAppBrowser

actual object KInAppBrowser

Android implementation of KInAppBrowser using Chrome Custom Tabs.

This implementation provides in-app browsing capabilities on Android using Chrome Custom Tabs, which offers better performance and user experience compared to WebView-based solutions.

expect object KInAppBrowser

This object provides a unified API for opening web URLs within your application using platform-specific in-app browser implementations:

  • Android: Uses Chrome Custom Tabs for better performance and user experience

  • iOS: Uses SFSafariViewController for secure browsing with Safari features

Android

class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

// Initialize KInAppBrowser with current activity
KInAppBrowser.init(this)

// Open URL in Chrome Custom Tabs
KInAppBrowser.open("https://example.com")
}
}

iOS

// No initialization needed - directly open URL
KInAppBrowser.open("https://example.com")

// Close Safari view controller when needed
KInAppBrowser.close()
actual object KInAppBrowser

iOS implementation of KInAppBrowser using SFSafariViewController.

This implementation provides in-app browsing capabilities on iOS using SFSafariViewController, which offers the full Safari browsing experience within your app while maintaining security and user privacy.

Functions

Link copied to clipboard
fun close()

Closes the currently presented SFSafariViewController.

Link copied to clipboard
fun init(activity: Activity)

Initializes KInAppBrowser with the provided Activity.

Link copied to clipboard
actual fun open(url: String)

Opens the specified URL in Chrome Custom Tabs.

expect fun open(url: String)

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

actual fun open(url: String)

Opens the specified URL in SFSafariViewController or system browser.