Skip to content

Preload Plan

Preload plans in advance and reuse them later without the internet during the app lifecycle.

Overview

  • Use ExpoFpPlan.preloader to preload plans.
  • A preloaded plan is represented by ExpoFpPreloadedPlanInfo.
  • You can obtain a presenter for a preloaded plan with getPreloadedPlanPresenter(...).
  • Recommended: Preload plans if you expect to reuse them multiple times in one session.
  • If a preloaded plan is reloaded with a new planLink, the link info is automatically updated in the stored ExpoFpPreloadedPlanInfo.

Step 1. Preload from the Internet

val expoKey = "YourExpoKey"

val preloadedPlanInfo = ExpoFpPlan.preloader.preloadPlan(
    planLink = ExpoFpLinkType.ExpoKey(expoKey)
)

With additional parameters

val additionalParams = listOf(URLQueryItem("noOverlay", "true"))
val locationProvider: IExpoFpLocationProvider = YourLocationProvider()
val messageListener: IExpoFpPlanMessageListener = YourMessageListener()

val preloadedPlanInfo = ExpoFpPlan.preloader.preloadPlan(
    planLink = ExpoFpLinkType.ExpoKey("YourExpoKey"),
    additionalParams = additionalParams,
    locationProvider = locationProvider,
    messageListener = messageListener
)

Step 2. Preload from Downloaded Plan

val preloadedPlanInfo = ExpoFpPlan.preloader.preloadPlan(
    planLink = ExpoFpLinkType.DownloadedPlanInfo(downloadedPlanInfo)
)

With additional parameters

val additionalParams = listOf(URLQueryItem("noOverlay", "true"))
val locationProvider: IExpoFpLocationProvider = YourLocationProvider()
val messageListener: IExpoFpPlanMessageListener = YourMessageListener()

val preloadedPlanInfo = ExpoFpPlan.preloader.preloadPlan(
    planLink = ExpoFpLinkType.DownloadedPlanInfo(downloadedPlanInfo),
    additionalParams = additionalParams,
    locationProvider = locationProvider,
    messageListener = messageListener
)

Step 3. Manage Preloaded Plans

Get all preloaded plans:

val preloadedPlansInfo: List<ExpoFpPreloadedPlanInfo> =
    ExpoFpPlan.preloader.getPreloadedPlansInfo()

Get a presenter from a preloaded plan:

val presenter = ExpoFpPlan.preloader.getPreloadedPlanPresenter(preloadedPlanInfo)

If only one plan is preloaded, you can get it without parameters:

val presenter = ExpoFpPlan.preloader.getPreloadedPlanPresenter()


Step 4. Show Preloaded Plan

View-based UI

val planView = presenter.getView()
container.addView(planView)

Jetpack Compose

AndroidView(factory = { presenter.getView() })

Step 5. Delete Preloaded Plans

Delete a specific plan:

val presenter = ExpoFpPlan.preloader.disposePreloadedPlan(preloadedPlanInfo)

Delete all plans:

ExpoFpPlan.preloader.removeAllPreloadedPlans()


Best Practices

  • Preload early: Preload plans during app initialization or screen preparation if you expect repeated access.
  • Reuse presenters: Get presenters from preloaded plans instead of creating new ones to reduce loading time.
  • Clear when not needed: Dispose preloaded plans when they are no longer needed to free memory.
  • Combine with download: Download plans to disk first, then preload them for faster reuse.