Miniwall Docs
Mobile SDK

Callbacks

Every callback the SDK calls, its arguments, what its return value means and in which order things happen.

Callbacks are options of present, embedded screens and auto placements. The Web SDK's onClose and onSkip have no callback here: the result of present is closed or skipped, and an embedded screen's onFinish receives the same result.

Signatures

var onPurchase: ((PurchaseRequest) async throws -> Bool)?
var onRestore: (() async throws -> Bool)?
var onAction: ((String, [String: Flow.Answer]) async -> Bool)?
var onAnswer: ((String, Flow.Answer?, [String: Flow.Answer]) -> Void)?
var onOpenURL: ((URL) -> Void)?
var onError: ((Error) -> Void)?

PurchaseRequest has packageId, product (your ProductInfo for that package, if you passed products) and answers.

CallbackReturn value
onPurchasetrue: purchased. false: cancelled. Throw: failed.
onRestoretrue: restored. false: nothing to restore. Throw: failed.
onActionfalse keeps the screen open. Anything else closes it.
onAnswernone
onOpenUrlnone
onErrornone

onPurchase

Run your purchase here. While it runs the screen shows a spinner and ignores taps.

  • Return true: the SDK records a purchase and present finishes with purchased and the packageId.
  • Return false (the user cancelled): a cancel is recorded and the screen stays open.
  • Throw: a purchase error is recorded, the screen stays open and onError receives the error.
  • If you pass no onPurchase, a purchase tap calls onError with Miniwall: pass onPurchase in PresentOptions to handle purchase buttons.

onRestore

The Restore purchases button only appears when you pass onRestore. App Store review expects a restore option on screens that sell subscriptions, so provide it when the screen sells one. Return false to say nothing was restored: the screen stays open. Otherwise a restore is recorded and present finishes with restored.

onAction

Called when a "Run your code" button is pressed. actionId is the ID set in the editor. It runs while the screen is busy. Screen changes ("Go to another screen", "Back to previous screen") do not call it. With no onAction, the screen closes and present finishes with action. In an embedded screen onFinish receives action.

onAnswer

Called each time a question changes. The value is the option ID, a list of option IDs for multiple choice, the typed text, or nothing once cleared. See Answers.

onOpenUrl

Called with the link a user pressed. The default opens it in the system browser. Only http, https, mailto, tel and links that start with a single / reach it. Others call onError.

onError

Receives errors from the renderer, from your own callbacks that throw, from linked screens that fail to load and from links that were refused. Load failures of present throw instead; in auto placements and embedded screens they go to onError.

Order for a purchase

  1. The user taps buy: purchase_click is recorded.
  2. onPurchase runs.
  3. A purchase (or cancel, or error) is recorded.
  4. present finishes with purchased, or the screen stays open.

On this page