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
| Source | Loads | Analytics |
|---|---|---|
| Placement | The 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 ID | That screen's published version. Needs the API key. | Yes |
| JSON | A 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:
- It sends the request with the last
ETagit saw, so an unchanged screen costs a short304answer. - 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).
- The Miniwall CDN caches an answer for about 30 seconds, so a publish reaches your app within about a minute.
- 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.
- 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:
| Field | What it is |
|---|---|
placement, paywallId, version | Which placement, screen and published version. |
paywall | The screen JSON. |
packages | The package IDs your app must price. |
experiment | A running A/B test: its id, shareB and side B's full delivery. null when none. |
rules | The audiences in order: id, conditions and the screen to show, or null for nothing. |
frequency | The frequency limit, or null. |
holdout | The holdout id and share, or null. |
display, trigger | The 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.