Launcher
Launcher is the entry point for LauncherKit, providing methods to create ExperienceView and ExperienceFragment instances backed by the given Core configuration.
Obtain an instance via Launcher.default or Launcher.from, then call getExperience or getExperienceFragment to embed a Monterosa experience in your UI.
@Composable
fun ExperienceScreen(core: Core) {
val lifecycleOwner = LocalLifecycleOwner.current
AndroidView(
modifier = Modifier.fillMaxSize(),
factory = { context ->
Launcher.from(core).getExperience(
context,
configuration = ExperienceConfiguration(
eventId = "<event-uuid>", // optional, omit for the whole project
hidesHeadersAndFooters = true,
autoresizesHeight = true
)
).apply {
listener = object : ExperienceViewListener {
override fun onReady(experienceView: ExperienceView) { }
override fun onUILoaded(experienceView: ExperienceView) { }
override fun onFailLoading(
experienceView: ExperienceView,
error: MonterosaSdkError
) { }
}
// lets the WebView pause and resume with the host
lifecycleOwner.lifecycle.addObserver(this)
}
},
onRelease = { experience ->
lifecycleOwner.lifecycle.removeObserver(experience)
experience.destroy()
}
)
}The view owns a WebView and a live bridge, so it must be torn down explicitly. onRelease is the right place in Compose; outside it, call ExperienceView.destroy when the host goes away. Leaving it out keeps the WebView, its threads and its connection alive.
To let the Experience sign the user in, hand it an IdentifyKit from the same Core with experience.identify = IdentifyKit.from(core). For Fragment-based hosting, use getExperienceFragment, which manages the view's lifecycle for you.
Functions
Obtain a configured ExperienceView
Obtain a configured ExperienceFragment embedding an ExperienceView