Get started with our SDK built for iOS and Android apps using React Native
publisherToken
and code
AdsProvider
. This component handles all data-fetching logic and requires access to the chat messages. Place it somewhere in your component tree where messages are already available and high enough in the hierarchy to contain all ad placements (i.e., locations where ads will be rendered).
Prop | Description |
---|---|
publisherToken | Your unique publisher token |
messages | A list of messages between the assistant and the user |
userId | A unique string that should remain the same during the user’s lifetime (used for retargeting and rewarded ads) |
conversationId | Unique ID of the conversation |
enabledPlacementCodes | A list of placement codes that should be enabled for the conversation |
character | The character object used in this conversation |
advertisingId | Device-specific identifier provided by the operating systems (IDFA/GAID) |
vendorId | Vendor-specific ID (IDFV) |
onAdView | A function that will be called when an ad is viewed (optional) |
onAdClick | A function that will be called when an ad is clicked (optional) |
variantId | A string provided by the publisher to identify the user cohort in order to compare A/B test groups (optional) |
messages
array includes objects with the following properties:
Prop | Description |
---|---|
id | Unique ID of the message |
role | Role of the message (user or assistant ) |
content | Content of the message |
createdAt | Timestamp when the message was created |
character
object includes the following properties:
Prop | Description |
---|---|
name | Name of the character |
avatarUrl | URL of the character’s avatar |
isNsfw | Whether the character is NSFW |
id | Unique ID of the character |
greeting | Greeting of the character |
persona | Description of the character’s personality |
tags | Tags of the character (list of strings) |
messages
to the AdsProvider
. This will allow you to decide the best ratio of ads to messages.
code
that you need to use for each ad slot or ad format you want to display.
We will be using an InlineAd
format in this example. 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
).