Miniwall Docs
Mobile SDK

Auto placements

Let placements show themselves when the app opens, after a delay or when your app reports an event, with one call.

Placements that have a trigger in the dashboard (see Screen and display) show themselves. Your app needs one call, once, after configure. A placement has one trigger: a website trigger or an app trigger. A website never fires app triggers and an app never fires page triggers.

@MainActor
static func startAutoPlacements(options: @escaping (String) -> PresentOptions = { _ in PresentOptions() },
                                onResult: ((String, PurchaseResult) -> Void)? = nil)

@MainActor
static func track(_ event: String)
Miniwall.configure(apiKey: "pk_...")

Miniwall.startAutoPlacements(
    options: { placement in
        var options = PresentOptions()
        options.products = prices
        options.onPurchase = { request in try await buy(request.packageId) }
        return options
    },
    onResult: { placement, result in print(placement, result) }
)

// Later, when something happens in the app:
Miniwall.track("level_completed")

Options

Auto placements take every present option except the display ones (the placement sets the format). On iOS and Android the options function runs each time a placement is about to show, so prices you load later are used and each placement can have its own handlers. On React Native and Flutter one set of options applies to all auto placements.

One extra callback:

OptionWhat it does
onResultCalled with the placement key and a PurchaseResult when a screen shown by a trigger finishes, or targeting chose to show nothing.

Load failures go to onError. They are never thrown.

Call startAutoPlacements once. Calling it again only replaces the options and the result callback.

Triggers

Trigger in the dashboardFires
When the app opensWhen the app starts and each time it comes back to the foreground from the background. On every N th time the app opens limits it to every Nth open (1 to 100; default 1). The count is kept on the device.
After N secondsN seconds (1 to 600) after the app opens.
When the app reports an eventWhen your app calls track with that event name. Names use lowercase letters, digits and underscores, start with a letter and have up to 40 characters.
When my code calls itNever by itself.

Page-based triggers (When the page loads, When the visitor scrolls, When the visitor is about to leave) are for websites and are ignored in apps.

The queue

  • One screen at a time. If a screen is open (automatic or yours), a trigger that fires is dropped.
  • By priority. If several fire at once, the highest Priority (0 to 100) goes first, then the placement created first. A placement that targeting skips (frequency limit, audience, holdout) lets the next one try; the ones after the first that shows are dropped for that moment.
  • Events before the list loads. An event reported before the placements list has loaded is kept and played when it arrives.
  • Your own call. You can call present at any time. A trigger that fires while any screen is open is dropped, not queued.

The list comes from GET /v1/sdk/auto?platform=ios (or android). It leaves out placements with no trigger, placements with a website trigger and placements with no published screen to show.

On this page