Load and Show Plan¶
This section explains how to load and display a plan using the SDK.
Overview¶
- A plan is managed by a presenter created with
ExpoFpPlan.createPlanPresenter(...). - The presenter provides a
WebViewviagetView().- In a View-based UI, you add this
WebViewinto your layout. - In Jetpack Compose, you use
AndroidViewto host theWebView.
- In a View-based UI, you add this
- You can optionally provide additional parameters, a location provider, and a message listener.
Step 1. Initialize the SDK¶
Call ExpoFpPlan.initialize(context) once, usually in Application or the first Activity.
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
ExpoFpPlan.initialize(this)
}
Step 2. Minimal Example (View-based)¶
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
ExpoFpPlan.initialize(this)
val presenter = ExpoFpPlan.createPlanPresenter(
planLink = ExpoFpLinkType.ExpoKey("demo")
)
val expoView = ExpoFpView(this).apply {
attachPresenter(presenter)
}
setContentView(expoView)
}
}
Step 3. Minimal Example (Jetpack Compose)¶
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
ExpoFpPlan.initialize(this)
val presenter = ExpoFpPlan.createPlanPresenter(
planLink = ExpoFpLinkType.ExpoKey("demo")
)
setContent {
AndroidView(
factory = { context ->
val planView = presenter.getView()
(planView.parent as? ViewGroup)?.removeView(planView)
FrameLayout(context).apply {
layoutParams = FrameLayout.LayoutParams(
FrameLayout.LayoutParams.MATCH_PARENT,
FrameLayout.LayoutParams.MATCH_PARENT
)
addView(planView)
}
},
modifier = Modifier.fillMaxSize()
)
}
}
}
Important: In Jetpack Compose, the plan's
WebViewmust be wrapped in aFrameLayout. Compose'sAndroidViewlayout system differs from the traditional Android View system. Without the wrapper, internal UI elements (bottom sheets, popups) may render as blank/white. In View-based UI,ExpoFpViewprovides this wrapper automatically.
Step 4. Advanced Initialization¶
You can customize the presenter by passing additional parameters, a location provider, and a message listener.
val expoKey = "YourExpoKey"
val additionalParams = listOf(ExpoFpPlanParameter.NoOverlay(true), ExpoFpPlanParameter.HideHeaderLogo(true))
val locationProvider: IExpoFpLocationProvider = YourLocationProvider()
val messageListener: IExpoFpPlanMessageListener = YourMessageListener()
val presenter = ExpoFpPlan.createPlanPresenter(
planLink = ExpoFpLinkType.ExpoKey(expoKey),
additionalParams = additionalParams,
locationProvider = locationProvider,
messageListener = messageListener
)