React Native
Platform guide for the Miniwall React Native module, covering install, API 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. Expo apps need a development build, because Expo Go cannot load native modules. Installation shows how to add it.
Everything in the other Mobile SDK pages applies. This page collects what is specific to React Native.
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 }.
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. Use any React Native billing library inside onPurchase.
Embedding
Inline embedding is available in the native SDKs only. See Embed a screen.