We are preparing a new v4 release of the React Native SDK. The documentation below covers the current shipping version — once v4 lands, this page will be updated.
React Native Demo Project
See how easy it is to integrate high-performance ads into your React Native app using our lightweight SDK.
Requirements
- React Native: 0.73.2 or later
Getting started
1. Installation
To get started, you will need to set up a publisher account to get a
publisherToken and code.2. Initialize AdsProvider
TheAdsProvider handles all data-fetching logic and must have access to the chat messages. Place it high enough in your component tree so it can contain all ad placements.
3. Set up IFA (Identifier for Advertisers)
- iOS: add
NSUserTrackingUsageDescriptiontoios/<YourApp>/Info.plist. The SDK auto-prompts for ATT and reads IDFA from there. - Android: the SDK adds the
com.google.android.gms.permission.AD_IDpermission via manifest merger automatically — no changes to yourAndroidManifest.xmlrequired.
4. Set up SKAdNetwork (iOS only)
Add the SKAdNetwork identifiers we provide during onboarding toios/<YourApp>/Info.plist. The SDK reads them and forwards them on every /init so DSPs can measure conversions.
See SKAdNetwork for the full guide.
5. Show your first ad
An ad slot is a designated area in your UI where an ad can be rendered. In most cases, it appears below a chat message. During onboarding, you’ll receive a uniquecode for each ad slot you plan to use.
Copy the markup <InlineAd /> and place it in your application where it should be rendered. Don’t forget to assign messageId as a unique identifier. For example, if you have a MessageList component, you can show an ad after each message like this (every message will have a unique ad displayed because of messageId).
API documentation
AdsProvider properties
Your unique publisher token.
List of messages between the assistant and the user.
Unique identifier that remains the same for the user’s lifetime (used for retargeting and rewarded ads).
Email of the user.
Unique ID of the conversation.
Placement codes enabled for the conversation. Example:
['inlineAd'].Character object used in this conversation.
Regulatory compliance information.TCF (Transparency and Consent Framework) signals —
gdpr and gdprConsent — are handled automatically by the SDK if you have a TCF-compliant CMP (Consent Management Platform) integrated in your app. You do not need to set these manually.Publisher-provided identifier for the user cohort (for A/B testing).
Callback triggered when an event occurs. See Supported events for more details.
Flag indicating if the ads are disabled.Note: This does not disable the display of old ads; that behavior is controlled by
staleAdsHandling.Determines how stale ads (ads not linked to the latest message) are handled.
preserve- keep displaying the last anchored ad until it’s replaced by a new adhide(default) - hide the ad when it becomes stale
InlineAd properties
Placement code provided during onboarding.
Unique ID of the message.
Theme of the ad, e.g.
light or dark.Wrapper function to wrap the ad content.
Supported Events
ad.clicked
The user has clicked the ad.
ad.viewed
The user has viewed the ad.
ad.filled
Ad is available.
ad.no-fill
Ad is not available.
ad.render-started
Triggered before the first token is received.
ad.render-completed
Triggered after the last token is received.
ad.error
Triggered when an error occurs.
reward.granted
Triggered when the user receives a reward.
video.started
Triggered when the video playback starts.
video.completed
Triggered when the video playback finishes.
Guides
Handling no-fill events
You can notify when the ad is not available by using theonEvent callback.