React Native
Requirements and the calls specific to the Miniwall React Native module, and how it relates to the native SDKs.
@miniwall/react-native is a thin layer over the iOS and Android SDKs. Screens are drawn natively; your JavaScript passes prices and runs the purchase. It needs React Native 0.74 or later, iOS 16 or later and Android 7.0 (API 24) or later. Installation shows how to add it (pod install for iOS, autolinking for Android). Expo apps need a development build, because Expo Go cannot load native modules. Everything in the other SDK pages applies; this page collects what is specific to React Native. For the web React components see React.
Calls
| Call | What it does |
|---|---|
configure(apiKey, options?) | Once at startup. Options: apiUrl, locale, colorMode, analytics, attributes, timeoutMs, maxFontScale |
present(source, options?) | source is { placement }, { paywallId } or { json } |
presentPlacement(name, options?) | Shorthand for present({ placement: name }) |
preload(placements) | Loads screens, images and fonts ahead of time |
setAttributes(values) | Audience attributes; null removes one |
reportPurchase({ packageId, paywallId }) | A purchase that finished outside the screen |
reset(placements?) | Forgets the visitor ID and counters |
startAutoPlacements(options?) and track(event) | See Auto placements |
period of a product is day, week, month, year, lifetime or { unit, count }.
The result of present is a plain object: { outcome: 'purchased', packageId, answers }, { outcome: 'restored', answers }, { outcome: 'closed', answers }, { outcome: 'action', actionId, answers } or { outcome: 'skipped', reason }. Load failures reject with code miniwall_error.
Handlers run in JavaScript
onPurchase, onRestore, onAction, onAnswer, onOpenUrl and onError are JavaScript functions. The native screen asks JavaScript and waits for the answer, and shows its busy spinner meanwhile. A handler that throws is reported to onError. If a handler does not answer within 10 minutes, the screen is released as "not bought" (see Callbacks). Use any React Native billing library inside onPurchase.
Embedding
Inline embedding is available in the native SDKs only. See Embed a screen.