Table of Contents
- Overview
- Basic Setup
- Screen-Based Visibility
- Global Delay
- Advanced: Visibility Groups
- Insets (Button Position)
- Complete Examples
- Field Reference
- Practical Scenarios
- Troubleshooting
- Summary
Overview
EmbedProvider wraps your app and:- Listens to React Navigation state and shows/hides the EmbedButton by screen.
- Supports visibility groups: per-group delay, continuity, and inset.
- Enriches analytics with screen context (current screen, path, depth).
- Use React Navigation (e.g.
@react-navigation/native). - EmbedProvider must wrap
NavigationContainerand receive the samerefyou pass toNavigationContainer.
Basic Setup
Minimal
appVersion(required): Your app version string (e.g. frompackage.json). Used in analytics.navigationRef: Ref attached toNavigationContainer. Without it, the provider cannot detect screen changes and will not show the button by screen.
With screen allowlist
Restrict the button to specific screens:includeScreens: Array of route names where the button may appear. If omitted or empty, the button can appear on all screens (subject to backend). Names must match your navigator’sname(e.g.Stack.Screen name="ScreenA").
Screen-Based Visibility
How it works
- You pass a ref from your root to both
EmbedProviderandNavigationContainer. - The provider subscribes to navigation state and reads the current route (deepest active screen).
- If the current screen is in
includeScreens(or in any visibility group when using groups), the button is shown; otherwise it is hidden.
Important
- EmbedProvider must wrap NavigationContainer so it can attach a listener to the same ref.
- Route names are case-sensitive and must match exactly (e.g.
'Screen1'not'screen1').
Global Delay
You can delay the first appearance of the button after entering an included screen:embedButtonDelayMs: Delay in milliseconds before showing the button on an included screen. Default is0(show immediately). This is the global default; groups can override it per group.
Advanced: Visibility Groups
For finer control (different delays, “stay visible” across screens, per-group position), use visibility groups.Concepts
| Concept | Meaning |
|---|---|
| Group | A set of screens that share delay/continuity/inset rules. |
| Continuity | Whether the button stays visible when moving between screens in the same group. |
| Delay policy | When the delay is applied: every screen, once per group entry, or once per app session. |
| Inset | Distance from screen edges (right, bottom, etc.) for the button. |
Types (import from package)
EmbedButtonVisibilityConfig
defaultDelayMs? You don’t need it if every group sets its own delayMs. It’s only used as a fallback when:
- A group does not set
delayMs– that group will usedefaultDelayMs, then the top-levelembedButtonDelayMs. - A screen is included (e.g. via
includeScreens) but doesn’t belong to any group – the provider usesdefaultDelayMs(orembedButtonDelayMs) for that screen.
defaultDelayMs and defaultInset when every group defines its own delayMs and inset.
EmbedButtonGroupConfig
EmbedButtonContinuity
'continuous'– When the user moves between screens in the same group, the button stays visible and the delay is not re-applied.'perScreen'– Each screen in the group is treated independently (delay can re-run per screen if policy allows).
EmbedButtonDelayPolicy
'perScreen'– Delay runs on every included screen in the group when you land on it.'oncePerGroupEntry'– Delay runs only when entering the group (first screen of that group in this “visit”). Moving to another screen in the same group does not re-trigger the delay (especially useful withcontinuity: 'continuous').'oncePerAppSession'– Delay runs only once per app session for that group. After the button has been shown once for that group, it shows immediately when returning to any screen in the group.
Including screens via groups
Screens listed in any group’sscreens array are treated as included even if you don’t list them in includeScreens. So you can:
- Rely only on groups (e.g.
includeScreens={[]}and define all included screens inside groups), or - Use both:
includeScreens+ groups; the final set of included screens is the union of both.
Insets (Button Position)
EmbedButtonInset controls how far the button sits from the edges of the screen:
- Values are typically numbers (e.g.
16,54). - You can set per-group
insetinEmbedButtonGroupConfig, or a default inEmbedButtonVisibilityConfig.defaultInset. - If nothing is set, the SDK uses an internal default (e.g.
right: 16,bottom: 20).
Complete Examples
Example 1: Multi-screen flow + confirmation screen
- Main flow: Screen1 → Screen2 → Screen3. Button appears after 1.5s when entering the flow and stays visible while moving between these screens. Inset
right: 16,bottom: 54. - Screen4: Single screen. Button appears after 1.5s once per app session. Inset
right: 24,bottom: 32. - Other screens: No button.
Example 2: Two screens with different delays
- ScreenA: Single screen, delay 1.5s every time you land on it, inset
right: 16,bottom: 24. - ScreenB: Single screen, delay 3s every time, inset
right: 16,bottom: 24.
Example 3: Include screens only via groups
NoincludeScreens; only group membership decides visibility:
screens array will get the button; all others will not.
Field Reference
EmbedProvider props
| Prop | Description |
|---|---|
children | The wrapped app or navigation container. |
navigationRef | A NavigationContainerRef passed to the provider so it can observe route changes. If omitted, the provider can create an internal ref. |
includeScreens | Array of screen names to allow button visibility. If empty or omitted, all screens are eligible. |
appVersion | Required. App version string, used in analytics. |
embedButtonDelayMs | Default delay (ms) applied per screen when no group config overrides it. |
embedButtonVisibilityConfig | Advanced configuration for grouping, continuity, and per-group delays/insets. |
EmbedButtonVisibilityConfig
| Field | Description |
|---|---|
defaultDelayMs | Used when a matched group does not specify delayMs. |
defaultInset | Default inset applied when a group does not specify an inset. |
groups | Array of EmbedButtonGroupConfig. |
EmbedButtonGroupConfig
| Field | Description |
|---|---|
id | Unique identifier for the group. |
screens | Screen names that belong to this group. |
continuity | 'continuous' – keep button visible across screens in this group; 'perScreen' – treat each screen as independent. |
delayMs | Delay (ms) before showing the button for this group. |
delayPolicy | 'perScreen' | 'oncePerGroupEntry' | 'oncePerAppSession'. |
inset | Offsets from edges: { top, right, bottom, left } (number or string). |
Practical Scenarios
Multi-step form flow (single delay)
Goal: Show delay once, then keep visible across steps.Same flow with extra standalone screens
Goal: Delay once for the flow, delay per screen for other screens.Avoid overlapping bottom UI
Goal: Push the button above a bottom tab bar.Troubleshooting
| Issue | What to check |
|---|---|
| Button never appears | 1) navigationRef is the same ref as on NavigationContainer. 2) EmbedProvider wraps NavigationContainer. 3) Current route name is in includeScreens or in a group’s screens. |
| Button on wrong screens | Route names in includeScreens / screens must match exactly (case-sensitive) the name prop of your screens. |
| Screen not interactive when button is visible | The overlay uses pointerEvents="box-none" so only the button receives touches; the rest should pass through. If not, ensure you’re on a version that includes this fix. |
| Button position wrong | Set inset per group or in defaultInset. The provider uses a full-screen overlay; insets are applied inside the EmbedButton container. |
| Delay not as expected | Check delayPolicy and continuity: oncePerGroupEntry + continuous keeps the button visible in the group and delays only on first entry; perScreen re-applies delay on every screen. |
| Types not found | Import from @revrag-ai/embed-react-native: EmbedButtonVisibilityConfig, EmbedButtonGroupConfig, EmbedButtonContinuity, EmbedButtonDelayPolicy, EmbedButtonInset. |
Summary
- EmbedProvider wraps NavigationContainer and receives the same navigationRef.
- Use includeScreens to allowlist screens, and/or embedButtonVisibilityConfig.groups for per-group delay, continuity, and inset.
- continuity: ‘continuous’ + delayPolicy: ‘oncePerGroupEntry’ gives a “one delay when entering the flow, then stay visible” behavior.
- embedButtonDelayMs and defaultDelayMs are fallbacks when a group doesn’t set delayMs.
- React Native Integration Guide – Installation, native setup, and SDK initialization.