Present a Funnel
Open a native funnel the way the editor says — full screen, modal or sheet — with the SDK buying for you, and get one result back.
presentFunnel resolves a placement and, when it serves a native funnel,
presents it the way the funnel's Presentation settings say: full screen
(from the bottom, from the side, a fade, or at once), as a modal card, or as
a bottom sheet at its heights (fit, medium, large). Nothing is
presented when the placement serves no funnel.
The SDK performs purchases and restores itself, closes after a successful one when Close after purchase is on (the default), and resolves once:
{ result: "completed" | "dismissed" | "unavailable", purchased, customerInfo?, lastError?, reason?, photos, answers /* Swift, Kotlin, Flutter: answersJson */, preselected }completed— the funnel finished, or closed after a purchase.dismissed— the visitor closed it (its close button, a swipe, back, a tap outside).unavailable— nothing was presented;reasonisalreadyPresented,noPresenter, or the placement's reason (no_placement,no_target, …).customerInfo— the entitlements and balances after a purchase, set wheneverpurchasedis true.answers(Swift, Kotlin, Flutter:answersJson) andpreselected— what the visitor answered; see The visitor's answers.
Call preloadPlacement at app start (and again after identify) and the
present is instant, with its store prices on the first frame; see
Store prices.
Default: the SDK buys
import { presentFunnel } from "@rovenue/react-native-sdk";
const { result, purchased } = await presentFunnel({ placement: "paywall" });
if (purchased) unlockPro();let outcome = await Rovenue.shared.presentFunnel(placement: "paywall")
if outcome.purchased { unlockPro() }
// SwiftUI
Button("Upgrade") { showPaywall = true }
.rovenueFunnel(isPresented: $showPaywall, placement: "paywall") { outcome in
if outcome.purchased { unlockPro() }
}lifecycleScope.launch {
val outcome = Rovenue.shared.presentFunnel(this@MainActivity, "paywall")
if (outcome.purchased) unlockPro()
}final outcome = await Rovenue.instance.presentFunnel('paywall');
if (outcome.purchased) unlockPro();Your app buys
Pass onPurchase (and onRestore) to perform them yourself. The funnel
waits for your answer, cannot be swiped away meanwhile, and then applies
Close after purchase as if the SDK had bought. The SDK refreshes
entitlements once to fill customerInfo.
await presentFunnel({
placement: "paywall",
onPurchase: async (packageId) => ({ purchased: await myStore.buy(packageId) }),
onRestore: async () => ({ purchased: await myStore.restore() }),
});let outcome = await Rovenue.shared.presentFunnel(
placement: "paywall",
handlers: FunnelPresentHandlers(
onPurchase: { packageId in await myStore.buy(packageId) },
onRestore: { await myStore.restore() }))Rovenue.shared.presentFunnel(
activity, "paywall",
handlers = FunnelPresentHandlers(
onPurchase = { packageId -> myStore.buy(packageId) },
onRestore = { myStore.restore() },
),
)await Rovenue.instance.presentFunnel(
'paywall',
handlers: FunnelPresentHandlers(
onPurchase: (packageId) => myStore.buy(packageId),
onRestore: () => myStore.restore(),
),
);React Native on Android: no JS timers while the funnel is up
The funnel runs in its own activity in front of your app's, and React Native
pauses JavaScript timers (setTimeout, setInterval) while your activity is
not in front. An onPurchase that waits on a timer stalls until the funnel
closes; await your purchase library's own promise instead.
A purchase the funnel sells at a win-back offer (a "offer": "win_back"
purchase the visitor is eligible for) carries the offer's id. React Native
passes it to onPurchase as a second argument; Swift, Kotlin and Flutter call
onWinBackPurchase(packageId, winBackOfferId) when you set it — buy with
purchase(…, winBackOffer:) using the offer from eligibleWinBackOffers with
that id. Without onWinBackPurchase, onPurchase gets the package and buys
at the regular price.
handlers: FunnelPresentHandlers(
onPurchase: (packageId) => myStore.buy(packageId),
onWinBackPurchase: (packageId, winBackOfferId) => myStore.buyWinBack(packageId, winBackOfferId),
),In React Native the funnel is answered exactly once however your callback
ends. Resolving { purchased } answers that value. An onPurchase or
onRestore that throws, rejects, or returns anything else answers "not
purchased", so a bug in your callback does not leave the funnel waiting. The
one case with no answer is a promise that never settles: there is no timeout,
because a purchase can take minutes (a bank approval, Ask to Buy). Always
settle it.
Observe purchase errors
onPurchaseError is observe-only: it reports a failed purchase or restore
the SDK performed. The paywall stays open; a cancelled store sheet is not an
error and is not reported. The result also carries lastError.
await presentFunnel({ placement: "paywall", onPurchaseError: (e) => log(e.kind, e.message) });await Rovenue.shared.presentFunnel(
placement: "paywall",
handlers: FunnelPresentHandlers(onPurchaseError: { error in log(error) }))Rovenue.shared.presentFunnel(activity, "paywall",
handlers = FunnelPresentHandlers(onPurchaseError = { error -> log(error) }))await Rovenue.instance.presentFunnel('paywall',
handlers: FunnelPresentHandlers(onPurchaseError: (e) => log(e)));The visitor's answers
The result carries every answer the funnel holds, by question key, whether
it completed or was dismissed: the same map a web funnel's claim carries
(What you get back).
Answers, set_variable results and the app values you passed in all sit in
it together. preselected lists the keys an app value preselected that the
visitor left unchanged, so a default can be told from a choice. Nothing is
answered when nothing was presented: the map is empty.
React Native hands the map back parsed (answers); Swift, Kotlin and
Flutter hand back its JSON object string (answersJson), as their claim
results do. Where the answers go from there is up to your app.
const { answers, preselected } = await presentFunnel({ placement: "onboarding" });
saveProfile(answers.exam_type, preselected.includes("exam_type"));let outcome = await Rovenue.shared.presentFunnel(placement: "onboarding")
let answers = try JSONSerialization.jsonObject(with: Data(outcome.answersJson.utf8))
saveProfile(answers, preselected: outcome.preselected)val outcome = Rovenue.shared.presentFunnel(activity, "onboarding")
val answers = Json.parseToJsonElement(outcome.answersJson).jsonObject
saveProfile(answers, preselected = outcome.preselected)final outcome = await Rovenue.instance.presentFunnel('onboarding');
final answers = jsonDecode(outcome.answersJson) as Map<String, dynamic>;
saveProfile(answers, preselected: outcome.preselected);While a purchase runs
From SDK 0.28.3, a presented funnel shows that a purchase or restore is
running. It does this whether the SDK performs it or your onPurchase /
onRestore does, and it needs no setting.
- The control that was tapped spins. A button with chrome (the call to action, a purchase button) swaps its label for a spinner in the label's colour. The label stays laid out, so the button keeps its size and nothing jumps. A chromeless button, such as a "Restore purchases" text link, keeps its label and shows a small spinner after it.
- Every other control dims and does nothing. Other buttons, the close button, the package list and the question options draw at half opacity and are disabled for assistive technology. The page takes no touch, so nothing navigates mid-purchase. Scrolling stops too, for the second or two the state lasts.
- It ends with the purchase. Success, cancel, error, Ask to Buy, a
restore that found nothing, a missing store product and a handler that
returns
purchased: falseall restore the page. A success that closes the funnel (Close after purchase) keeps the state until the funnel is gone, so the paywall does not flash back during the exit. - Assistive technology reads the spinning control with its label and the state "Processing…" (in the visitor's language).
An embedded RovenueFunnelView, where your app performs the purchase and may
never report a failure, does not show this: a spinner could stay on forever
for a host that only reports success. Web funnels are unchanged too; the
runner's payment step has its own progress UI.
The purchase overlay
A funnel can also dim itself and show a message while a purchase runs, so the
visitor sees something during store verification, after the system sheet has
closed. It is off until the funnel's presentation has a purchaseOverlay
key. Set it in the editor under Settings › Presentation, or through
update_funnel.
{
"presentation": {
"purchaseOverlay": {
"logo": "https://cdn.example.com/logo.png",
"title": { "en": "Activating Pro", "tr": "Pro etkinleştiriliyor" },
"description": { "en": "This takes a few seconds.", "tr": "Bu birkaç saniye sürer." },
"spinner": true,
"scrimOpacity": 48
}
}
}Every field is optional.
| Field | Type | Default | Limit |
|---|---|---|---|
logo | image URL | none | https, or http on a local host; the editor fills it from the asset library |
title | locale map | none | 60 characters per locale |
description | locale map | none | 200 characters per locale |
spinner | boolean | true | |
scrimOpacity | whole percent | 48 | 0 to 100 |
- The dim is black at
scrimOpacity, over the funnel's own bounds (the sheet in a sheet, the screen in full screen). It fades in when the purchase starts, beneath the system store sheet, and out when it ends. With Reduce Motion or animations off there is no fade. It blocks every touch and moves assistive focus to itself. - With a logo, title or description, they sit centred in a card: logo,
spinner, title, description. With none of the three, the overlay is the
spinner alone on the dim, so
"purchaseOverlay": {}is the whole "just a spinner" overlay.spinner: falsewith no copy is a bare dim; the tapped button's own spinner still shows through it. titleanddescriptionare locale maps only (not a bare string). They resolve in the visitor's language, then the funnel's default language; a blank result counts as none. Assistive technology announces the title, or "Processing…" when there is none. Adding a language to the funnel adds an empty entry that the Localization tab lists as missing.- It applies to restores as well as purchases, and the busy button state stays underneath it.
- A value outside these limits is refused at publish with
PURCHASE_OVERLAY_INVALID.
Native only, and not a present option
The overlay is part of the funnel document, so it is not an option of
presentFunnel and cannot be overridden per call. A web funnel refuses the
whole presentation block. SDKs before 0.28.3 ignore purchaseOverlay and
show neither the overlay nor the busy state; nothing breaks, and the funnel
config format stays 6.
A pending purchase
From SDK 0.30.0, when the SDK buys and the purchase comes back deferred
(isDeferred, no access granted yet), the funnel
says so instead of quietly returning to the paywall, where the visitor might
pay again. The busy state ends as usual, and a notice opens over the funnel:
pendingReason | Title | Detail |
|---|---|---|
verification — the store charged, and the SDK is still verifying the purchase with the server (see Processing purchases) | Payment received | We're activating your access — this can take a moment. |
storeApproval — Ask to Buy, or a pending payment on Google Play | Waiting for approval | We'll unlock it as soon as the purchase is approved. |
- The notice is a card with the title, the detail and a Continue button, over the authored purchase overlay's dim and logo when the funnel has one, else over the presentation's own dim. It has no spinner. Continue (or back on Android) puts it away; the funnel stays open and can still be closed, because Ask to Buy can take days.
- The same package cannot be bought again while it is pending: every control that would buy it (the purchase button, a call to action, button or option whose actions buy) is drawn disabled with its label, and a tap does nothing. Picking another package and buying that works as usual.
- When the purchase lands — the SDK's verification retry succeeds, the
purchase is approved, or the server grants it — the funnel goes on exactly
as after any successful purchase: to its After purchase page, or closed
with
completedwhen Close after purchase is on. The SDK takes it as landed when an entitlement for that product becomes active, or, for a one-time product, when a virtual-currency balance rises. A product that grants neither cannot be seen landing: the notice stays until the visitor puts it away. - If the visitor closes the funnel first, the SDK stops watching. The purchase
still lands on its own; your app hears it through the change listener
(
ENTITLEMENTS_CHANGED/VIRTUAL_CURRENCIES_CHANGED), as for any deferred purchase.
The copy is the SDK's own, in the 10 languages funnel chrome ships in, and
assistive technology announces the title and detail. A purchase your
onPurchase performs, and an embedded RovenueFunnelView whose host buys,
show no notice: the SDK does not know the purchase is pending. Web funnels
are unchanged.
Override the style
style overrides the funnel's own presentation field by field; a style
changed here with no dismissible takes that style's default (a full screen
is not swipe-dismissible, a modal or sheet is).
import { presentFunnel } from "@rovenue/react-native-sdk";
await presentFunnel({ placement: "paywall", style: { style: "sheet", detents: ["medium", "large"] } });One at a time
A second presentFunnel while one is up resolves unavailable with reason
alreadyPresented. On Android the funnel runs in the SDK's own translucent
activity (merged from the library manifest), so rotation and dark-mode
changes keep the page and answers.
Every page needs a way out
A funnel whose presentation cannot be swiped away (the full-screen default)
must give every reachable page a way out: a close button, finishing the last
page, or a purchase that ends the funnel. A purchase ends it when
Close after purchase is on (the default), or when it is off and the
page's After purchase page leads to a way out. A page with none is a dead
end, and publishing refuses it (PRESENTATION_NOT_CLOSABLE).
Hard paywalls
A hard paywall is a full-screen paywall with no close: the visitor buys,
restores, or stays. It publishes, and the editor marks it with a Hard
paywall badge in Settings › Presentation and on the page list. A successful
purchase closes it with completed. A restore that unlocks access closes it
the same way, whether the SDK restores or your onRestore does.
App Review accepts hard paywalls. It does not require a close button, but it does require these on the paywall:
- A Restore button: a button whose actions include
restore_purchases(guideline 3.1.1). Without one, the funnel still publishes, with the warningHARD_PAYWALL_NO_RESTORE. - Links to your subscription terms, privacy policy and EULA (guideline 3.1.2). Point them at the project links under Settings.
A sheet or modal the visitor can swipe away is never a hard paywall.
For the rest of what App Review checks on a remote paywall, and what to write in Notes for Review, see Pass App Review.