Miniwall Docs
Mobile SDK

Preload and sources

Load screens, images and fonts ahead of time, list a screen's package IDs, and learn how sources, caching, timeouts and the offline copy work.

preload fetches placements' screens, their images and their fonts without showing anything, so present opens at once. It sends no analytics events. It is the Mobile SDK's counterpart of the Web SDK's loadPaywall.

await Miniwall.preload(placements: ["onboarding", "upgrade_button"])

let ids = Miniwall.packageIds(in: paywallJSON) // ["monthly", "annual"]

A placement that cannot be loaded is skipped silently: preload never throws.

Sources

SourceLoadsAnalytics
PlacementThe screen the placement shows now. A schedule in force is applied by the server. For an A/B test, the user's side is picked. Audiences, the frequency limit and the holdout are decided when you present. Recommended. Needs the API key.Yes (when presented)
Paywall IDThat screen's published version. Needs the API key.Yes
JSONA screen JSON you bundle in the app, as it is.None

A JSON source must have the screen format: default_locale, components_config.base and components_localizations. Download a screen's JSON from the dashboard with Download JSON on the Screens page. Because a downloaded file is a copy, it does not change when you publish. A placement does.

Caching and the offline copy

For a placement or a paywall ID the SDK keeps its own copy of the last answer:

  1. It sends the request with the last ETag it saw, so an unchanged screen costs a short 304 answer.
  2. The copy is kept on disk in the app's cache. Fonts are kept in the cache directory too. Images are cached for the session (and on disk on iOS).
  3. The Miniwall CDN caches an answer for about 30 seconds, so a publish reaches your app within about a minute.
  4. If the network fails, the request times out, or the server answers with a 5xx error, the last copy is used. A published screen keeps working offline.
  5. A 4xx answer (a wrong key, an unknown placement) is an error, even if there is a copy.

The timeout (default 8 seconds, set in configure) is how long to wait. After that the saved copy is used. With no copy the call fails with Miniwall: the screen took too long to load.

The delivery response

For reference, the SDK calls GET {apiUrl}/v1/sdk/placements/KEY?key=pk_...&v=2 (or /v1/sdk/paywalls/ID), with the header X-Miniwall-SDK: ios/0.1.0 (or android/0.1.0). The answer contains the published screen and everything the app needs to decide what to show:

FieldWhat it is
placement, paywallId, versionWhich placement, screen and published version.
paywallThe screen JSON.
packagesThe package IDs your app must price.
experimentA running A/B test: its id, shareB and side B's full delivery. null when none.
rulesThe audiences in order: id, conditions and the screen to show, or null for nothing.
frequencyThe frequency limit, or null.
holdoutThe holdout id and share, or null.
display, triggerThe placement's format and trigger.

Audiences, the frequency limit and the holdout ship as rules and are decided on the device, so your users' attributes never leave the app. See Targeting attributes.

On this page