Show a Funnel
Host a placement's native funnel in RovenueFunnelView on every SDK, and the events it reports.
Install the SDK first — iOS, Android, React Native, Flutter — then resolve the placement and host the view. There is no web tab: sdk-web draws no funnel; web funnels are hosted at a URL instead (see Hosting).
Give the view a placement identifier and it resolves the placement itself,
draws what it serves and reports what happened through the
events below — the same six on every SDK. A placement that holds
no funnel (unknown, retired, target: none) is not an error: the view draws
nothing and reports onUnavailable. On React Native and Flutter there is
deliberately no JS/Dart getFunnel — nothing about a funnel crosses the
bridge; the widget hosts the native view, which resolves the placement
(packages/sdk-rn/src/funnel-view/RovenueFunnelView.tsx,
packages/sdk-flutter/rovenue_flutter/lib/src/funnel_view.dart).
In a debug build on a Sandbox key (rov_pk_test_…) the placement serves each
funnel's latest draft. The view draws it with a small "Draft" badge and
keeps it live: an edit in the builder arrives within a few seconds, on the
screen you are on when it still exists. A draft that cannot be served shows
its issues instead. A release build, or a live key, always gets the
published funnel.
@MainActor func onboardingFunnel() -> RovenueFunnelView {
RovenueFunnelView(
placementId: "onboarding",
locale: "en",
handlers: FunnelHostHandlers(
onCustom: { actionId, paramsJson in print(actionId, paramsJson) },
onPurchase: { packageId in print(packageId) },
onRestore: { print("restore requested") },
onCompleted: { print("completed") }
)
)
}
_ = onboardingFunnelRovenueFunnelView(placementId:locale:handlers:) resolves the placement and
draws it; a new placementId or locale resolves again, clearing the
previous funnel first
(packages/sdk-swift/Sources/Rovenue/FunnelUI/RovenueFunnelView.swift).
A custom action arrives as onCustom with its id and params JSON, a
purchase step as onPurchase with the package id, a restore step as
onRestore. Every handler is optional; an effect with no handler is
dropped, never fatal.
To drive a session yourself, Rovenue.shared.getFunnel(placementId:locale:)
returns .funnel(ResolvedFunnel) or .unavailable(FunnelUnavailable); hand
funnel.session to a FunnelDriver and the driver to
RovenueFunnelView(driver:). That view is a fixed snapshot: no resolve
events and no live draft refresh. Persist driver.stateJson() to resume the
same presentation next launch (see
Purchases & effects).
import android.content.Context
import dev.rovenue.sdk.funnelui.FunnelHostHandlers
import dev.rovenue.sdk.funnelui.RovenueFunnelView
fun showOnboarding(context: Context): RovenueFunnelView {
val view = RovenueFunnelView(context)
view.setPlacement(
placementId = "onboarding",
locale = "en",
handlers = FunnelHostHandlers(
onCustom = { actionId, paramsJson -> println("$actionId $paramsJson") },
onPurchase = { packageId -> println(packageId) },
onRestore = { println("restore requested") },
onCompleted = { println("completed") },
),
)
return view
}setPlacement(placementId, locale, handlers) resolves the placement and
draws it; a new placement or locale resolves again, clearing the previous
funnel first, and the same pair is a no-op
(packages/sdk-kotlin/src/main/kotlin/dev/rovenue/sdk/funnelui/RovenueFunnelView.kt).
Call view.close() when the host takes the view away for good, so the
presentation's dismissal is recorded once. Every handler is optional:
onCustom carries the action id and its params as JSON, onPurchase the
package id to buy, onRestore the restore request.
To drive a session yourself, Rovenue.shared.getFunnel(placementId, locale)
returns FunnelResolution.Funnel or FunnelResolution.Unavailable; wrap
funnel.session in a FunnelDriver and attach it with bind(driver) — a
fixed snapshot, with no resolve events and no live draft refresh.
The widget hosts the platform's native funnel renderer for the placement —
the native side resolves and draws, so there is no JS getFunnel and no
object to pass in
(packages/sdk-rn/src/funnel-view/RovenueFunnelView.tsx).
import { RovenueFunnelView } from "@rovenue/react-native-sdk";
function OnboardingFunnel() {
return (
<RovenueFunnelView
placementIdentifier="onboarding"
locale="en"
onLoaded={(e) => console.log(e.funnelId, e.isDraft)}
onUnavailable={(e) => console.log(e.reason)}
onCompleted={() => undefined}
onDismissed={() => undefined}
/>
);
}Size it with your own flex container — the funnel fills whatever frame the
host gives it. onCompleted fires when the funnel reaches its end and
onDismissed when the visitor closes it — never both; remove the view there.
A new placementIdentifier resolves again, clearing the previous funnel
first. Omit
onUrl to leave open_url actions inert — the funnel never navigates itself.
A legal block's terms link goes to onUrl too; with no handler it opens only
an http/https address, in the system browser, and any other scheme does
nothing — the same rule on iOS, Android and the web. Whether a handler exists
is decided when the funnel resolves: removing onUrl later stops URLs
reaching your code, and adding one later takes effect on the next resolve.
import { RovenueFunnelView } from "@rovenue/react-native-sdk";
function OnboardingFunnelActions() {
return (
<RovenueFunnelView
placementIdentifier="onboarding"
onCustomAction={(action) => console.log(action.actionId, action.params)}
onPurchase={(packageId) => console.log(packageId)}
onRestore={() => console.log("restore requested")}
/>
);
}A custom action arrives parsed as FunnelCustomAction — actionId plus an
already-decoded params map; malformed params JSON yields {}, never a
throw inside the native callback. onPurchase
hands you the package id to buy with Rovenue.purchase; onRestore asks
for restorePurchases.
The widget hosts the native funnel renderer — SwiftUI's
RovenueFunnelView on iOS, dev.rovenue.sdk.funnelui.RovenueFunnelView on
Android — as a platform view
(packages/sdk-flutter/rovenue_flutter/lib/src/funnel_view.dart).
RovenueFunnelView buildOnboardingFunnel(void Function(String) log, void Function() done) {
return RovenueFunnelView(
placementIdentifier: 'onboarding',
onLoaded: (loaded) => log('${loaded.funnelId} ${loaded.isDraft}'),
onUnavailable: (unavailable) => log(unavailable.reason.wireName),
onCompleted: done,
onDismissed: done,
);
}The funnel fills whatever space the parent gives it; size it with a
SizedBox/Expanded. onCompleted fires when the funnel reaches its end
and onDismissed when the visitor closes it — never both.
Changing placementIdentifier on a live instance resolves again, clearing
the previous funnel first, and restarts at the first screen.
RovenueFunnelView buildOnboardingFunnelActions(void Function(RovenueFunnelAction action) onAction) {
return RovenueFunnelView(
placementIdentifier: 'onboarding',
onCustomAction: onAction,
onPurchase: (packageId) {},
onRestore: () {},
);
}RovenueFunnelAction carries the app-defined action id and its
already-decoded params
.
onPurchase hands you the package identifier to buy with
Rovenue.instance.purchase; onRestore asks for restores.
Omit onUrl to leave open_url actions inert. A legal block's terms link
goes to onUrl too; with no handler it opens only an http/https address in
the system browser, and any other scheme does nothing.
Presence is sent as hasUrlHandler and decided when the funnel resolves:
removing onUrl later stops URLs reaching your code, and adding one later
takes effect on the next resolve.
Events
The view reports the same six events on every SDK — Swift and Kotlin
FunnelHostHandlers, the React Native RovenueFunnelView props and the
Flutter RovenueFunnelView callbacks:
| event | when | payload |
|---|---|---|
onLoaded | the first screen is on screen. For a draft it fires again after every live-refresh rebuild. | placementId, funnelId, revision, variantId?, experimentKey?, servedFromFallback, isDraft |
onUnavailable | the view has nothing to draw | placementId, reason, issues? — reason is empty_placement_id, no_placement, no_target, no_variants or draft_issues; issues only for draft_issues |
onError | resolving failed — offline with no cache or fallback, an invalid or unsupported config — or a screen did not decode | the SDK's error: its code (FUNNEL_SCREEN_UNDECODABLE for an undecodable screen), message and whether it is retryable |
onScreenChanged | the visible screen changes, including the first | screenId, index (from 0) |
onCompleted | the funnel reached its end | — |
onDismissed | the visitor dismissed it (its close action) | — |
- An empty or unknown placement sends
onUnavailable(empty_placement_id,no_placement); it never sends nothing. - On
onUnavailableandonErrorthe previous funnel is cleared, so a stale funnel never stays on screen. - A resolve superseded by a newer one (the placement changed again) reports
nothing — no
onError, noonLoaded. onCompletedandonDismissednever both fire for one presentation, and neither fires when the host takes the view away itself (unmounting it, orclose()/driver.close()); that is recorded as a dismissal in analytics but not reported back.- A draft that cannot be served reports
onUnavailable(draft_issues)with its issues, and the view draws them; a draft deleted while it is on screen reportsonUnavailable(no_target).
Per SDK, the payloads are typed: Swift FunnelLoaded, FunnelUnavailable
(reason.wireName is the spelling above), RovenueError, FunnelScreen;
Kotlin the same names with RovenueException; React Native
FunnelLoadedEvent, FunnelUnavailableEvent, RovenueError (serverCode,
kind, isRetryable), FunnelScreenEvent; Flutter RovenueFunnelLoaded,
RovenueFunnelUnavailable (reason.wireName), RovenueException
(serverCode, kind, retryable), RovenueFunnelScreen.
What happens inside the session — effects, purchases, restore and resume — is next: Purchases & effects.