Widget guides / Android
Chat widget in your Android app
Add our wrapper files to your app and visitors get a chat that answers questions about matches, teams and players, with stats and your prices. This guide covers every setting, callback and object the wrapper gives you.
The wrapper is written in Kotlin with Android Views (a FrameLayout launcher and a Material bottom
sheet), not Jetpack Compose. A Compose screen can host the launcher through AndroidView.
Checklist:
- Get your operator id, public key, widget origin and the wrapper files from your SensibleStats contact.
- Ask your contact to switch mobile on for your account.
- Add the files, create the chat in a
ViewModelwith the signed-in visitor's id, and bind your activity. - Set
onAddToSlip, then test an add, a duplicate and a reject. - Set
onUnavailable, and reload the chat when the visitor signs in or out.
1. What your visitors get#
- A chat icon in a bottom corner, with a teaser beside it: a short greeting about a game, often with one of your prices and a few suggested questions.
- A chat sheet where visitors ask in their own words and get answers as text and cards: stats, form, line-ups, standings and your prices.
- Add to slip. A price in the chat carries a button that hands the selection to your code (section 7).
Terms used in this guide:
- Wrapper is the set of Kotlin files your SensibleStats contact sends you. It shows our chat page
https://your-widget-host/min a WebView and passes messages between that page and your code. You never build the page URL yourself. - Operator id and public key identify your account to our server.
- Widget origin is the address of our server for your account, shown here as
https://your-widget-host. - Teaser is the short greeting bubble above the chat icon.
- Bet slip (or slip) is the list of selections a visitor collects in your app before placing a bet.
- Price is your odds for one selection.
matchOddsIdis your sportsbook's own id for one selection: one outcome of one market.operatorUserIdis your id for the signed-in visitor (section 5).
2. Before you start#
You need three values and the wrapper files from your SensibleStats contact.
| From us | Example | What it is |
|---|---|---|
| Operator id | YOUR_OPERATOR_ID | Your account in our system. Part of every request. |
| Public key | YOUR_PUBLIC_KEY | Identifies your widget. Safe to ship inside your app. |
| Widget origin | https://your-widget-host | The address the chat page loads from. Goes in baseUrl. |
| To us | What it is |
|---|---|
| Switch on mobile | Ask your contact to switch mobile on for your account. Until then the chat reports mobile_disabled (section 11). There is no list of allowed domains for mobile. |
Your app also needs:
| Requirement | Value |
|---|---|
minSdk | 24 or higher. |
| Language | Kotlin, Java 17 target. |
| Activity | A FragmentActivity (for example AppCompatActivity) that implements ChatOwner. |
| Permission | android. in AndroidManifest.. |
| Build feature | buildConfig = true: the wrapper reads BuildConfig.. |
Dependencies the wrapper files use:
implementation("androidx.appcompat:appcompat:1.7.0")
implementation("androidx.activity:activity-ktx:1.10.1")
implementation("androidx.fragment:fragment-ktx:1.8.6")
implementation("androidx.webkit:webkit:1.12.1")
implementation("com.google.android.material:material:1.12.0")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.10.1")
// for the ViewModel and repeatOnLifecycle samples below
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.8.7")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.8.7")3. Add the widget#
Add these files, which your SensibleStats contact sends you, to your app module:
| File | Needed | What it holds |
|---|---|---|
SensibleStatsConfig. | Yes | SensibleStatsConfig and the types it uses. |
SensibleStatsChat. | Yes | SensibleStatsChat (the WebView, the bridge and the chat sheet), and the slip and teaser types. |
SensibleStatsLauncher. | No | SensibleStatsLauncher, our icon and teaser. Leave it out if you draw your own (section 8). |
themes. styles ChatSheetDialog and ChatSheetStyle | Yes | The chat sheet's style, built on Material 3 parents. Copy both styles into your own res/. |
Change the package line of each file to your own package, so that BuildConfig and R resolve
to your app's. Members marked internal are not part of the API; don't call them.
SensibleStatsChat.WRAPPER_VERSION holds the wrapper's version, "1.0.0" today. Quote this value
when you contact us; your contact tells you when to update.
Create the chat once, in a ViewModel, so it outlives screen rotation. Pass the application, not
the activity:
fun chatConfig(userId: String) = SensibleStatsConfig(
baseUrl = "https://your-widget-host",
operatorId = "YOUR_OPERATOR_ID",
publicKey = "YOUR_PUBLIC_KEY",
userContext = UserContext(userId),
locale = "en-GB",
greetingMessage = "hello",
)
class ChatViewModel(application: Application) : AndroidViewModel(application) {
val chat = SensibleStatsChat(application, chatConfig(currentUser.id))
override fun onCleared() {
chat.destroy()
}
}Names that start with my or My, and currentUser, stand for your own code.
Your activity implements ChatOwner (the chat sheet finds the chat through it), binds the chat,
sets the slip handler and adds the launcher on top of its content:
class MainActivity : AppCompatActivity(), ChatOwner {
private val model: ChatViewModel by viewModels()
override val chat: SensibleStatsChat get() = model.chat
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
chat.bind(this)
chat.onAddToSlip = { selection -> mySlip.add(selection) }
val root = FrameLayout(this)
root.addView(myContent)
root.addView(SensibleStatsLauncher(this, chat))
setContentView(root)
}
override fun onDestroy() {
if (chat.unbind(this)) chat.onAddToSlip = { SlipResult.Rejected(RejectReason.UNSUPPORTED) }
super.onDestroy()
}
}Here mySlip.add is a suspend function that returns a SlipResult? (section 7). The chat starts
loading as soon as it is created. The launcher shows once the page is ready.
Lifecycle.
| Call | When | What it does |
|---|---|---|
SensibleStatsChat( | Once, in a ViewModel. | Creates the WebView and loads the chat page. Throws IllegalArgumentException if baseUrl is not an https URL with a host. |
chat. | In every onCreate. | Lets the chat open its sheet over this activity. open() does nothing until an activity is bound. |
chat. | In onDestroy. | Returns true if that activity was the bound one. Replace any callback that holds the activity's views then, as above, so the old activity is not kept alive. |
chat. | In the ViewModel's onCleared. | Stops the chat and destroys the WebView. Don't use the chat afterwards. |
Declare android:configChanges="orientation|screenSize|screenLayout|smallestScreenSize|keyboardHidden|uiMode"
and android:windowSoftInputMode="adjustResize" on the activity.
4. Settings#
All settings are fields of SensibleStatsConfig.
Required#
| Field | Type | What it does |
|---|---|---|
baseUrl | String | https://your-widget-host. Must be https with a host. Only scheme, host and port are used; any path is replaced. |
operatorId | String | Your operator id. |
publicKey | String | Your public key. |
userContext | UserContext( | The signed-in visitor. See section 5. |
An empty operatorId or publicKey makes the chat report AUTH_FAILED.
Visitor, language and time#
| Field | Type | Default | What it does |
|---|---|---|---|
locale | String?, language tag, e.g. en-GB, tr | your account's default language (English unless you asked for another) | The language of the chat and its answers. |
timeZone | String?, IANA zone, e.g. Europe/ | the device's zone | Kick-off times and day names follow this zone. |
oddsFormat | OddsFormat?: DECIMAL, AMERICAN, FRACTIONAL | decimal | How prices are written. A visitor who picks a format in the chat's settings keeps their choice. |
Greeting and page#
| Field | Type | Default | What it does |
|---|---|---|---|
greetingMessage | String? | null | The chat sends this once when the page loads, and the answer becomes the teaser. Use "hello". Without it there is no greeting and no teaser. |
page | PageContext? | null | The screen the visitor is on, so the greeting can lead with it. Section 6. |
placeholder | String? | localized | Text in the empty question box. |
starters | List<String>? | null | Suggested questions shown in an empty chat. Don't use | inside a question: the list is sent joined by |. |
Look#
| Field | Type | Default | What it does |
|---|---|---|---|
theme | Theme: LIGHT, DARK, AUTO | AUTO | AUTO follows the device's dark mode. A visitor who picks a theme in the chat keeps their choice. |
colors | Colors? | our colours | Colors(. Section 10. |
logoUrl | String?, https or data: URL | our mark | Your square logo, shown on the icon and in the chat header. A data: URL must be base64. |
headerTitle | String? | SensibleStats | The chat's title. |
radius | Double? | 16 | Corner radius of the chat, in px. Only finite values from 0 are sent. |
pinIcon | PinIcon?: PIN, STAR, BOOKMARK | pin | The icon visitors tap to follow a match or price. |
launcher | Boolean | true | false hides our icon and teaser so you draw your own (section 8). |
position | Position: LEFT, RIGHT | RIGHT | Which bottom corner the icon sits in. |
offset | Offset( | 20, 20 | Distance in dp from the side and from the bottom, on top of the system bars. |
launcherLabel | String? | "Chat with SensibleStats", localized | The icon's label for screen readers. Blank counts as unset. Until the page answers, the icon's label is English "Open chat". |
Slip, callbacks and events#
Callbacks are properties of the chat, not of the config.
| Setting | Type | What it does |
|---|---|---|
chat. | suspend ( | Adds a price to your bet slip. Section 7. |
config. | List<SlipSport>?: BASKETBALL, AMERICANFOOTBALL, TENNIS | The sports your onAddToSlip accepts besides football. Section 7. |
chat. | ( | Gives you the teaser to draw yourself. Section 8. |
chat. | ( | Tells you the chat cannot start. Section 11. |
chat. | ( | Every chat event, for your own analytics. Section 9. |
config. | Boolean, default false | Adds the visitor's question text to question_asked events. Answer text is never sent. |
chat. | (, default null | For debugging only: sees every raw message between the app and the page. It cannot change them. Leave it unset in release builds: it sees visitor ids. |
Callbacks run on the main thread. If onTeaser, onEvent or onUnavailable throws, the wrapper
logs it with Log.w and carries on; your app does not crash.
5. The signed-in visitor#
A signed-in visitor is required. Pass your id for them in UserContext(operatorUserId). Use a
random, non-guessable id that never changes for that account and that you map to the customer on your
side (a UUID works). Never use a customer number, email address or name: the id comes from the
visitor's device, and anyone who knows it can act as that visitor. A blank id means no visitor: the
chat does not start and reports NO_USER (section 11).
With the id, the visitor's chat, followed matches and favourites belong to their account, and the greeting can lead with the teams and markets they bet on.
When the visitor signs in or switches account, reload the chat with a config for the new visitor:
chat.reload(chatConfig(newUserId))When the visitor signs out, reload with a blank id. The chat closes, the icon hides and
onUnavailable(NO_USER) is called:
chat.reload(chatConfig(""))reload keeps the same chat object and WebView. It clears the teaser, drops calls not yet
delivered, resets available and unavailableReason, and reopens the sheet once the page is ready
if it was open. The new config must use the same baseUrl origin; another origin throws
IllegalArgumentException, so create a new SensibleStatsChat for it.
6. The page the visitor is on#
Tell the chat which screen it sits on and the greeting leads with that game, competition or sport.
page = PageContext(sport = Sport.FOOTBALL, kind = PageKind.MATCH, matchId = PageId.of(19432556L))| Field | Type | Meaning |
|---|---|---|
sport | Sport: FOOTBALL, BASKETBALL, AMERICANFOOTBALL, TENNIS | Required. |
kind | PageKind?: SECTION, COMPETITION, MATCH | A sport's front page, a competition page, or a match page. |
matchId | PageId? | Your sportsbook's id for the match on a match screen. |
competitionId | PageId? | Your sportsbook's id for the competition on a competition screen. |
A PageId is a number or text: PageId.of(19432556L) or PageId.of("your-match-id").
When the visitor moves to another screen, call chat.setPage(page), or chat.setPage(null) on a
screen that is about no sport. setPage only tells the page that is loaded now. After reload the
chat starts from config.page, so put the current screen in the config you reload with.
7. Add to slip#
The chat shows your prices, each with an "Add to slip" button. This is how a tap reaches your slip:
- The visitor taps "Add to slip" under a price.
- The wrapper calls
chat.onAddToSlip(selection).selection.matchOddsIdis your sportsbook's own id for that selection, so you can look it up directly. - Your code adds that selection to your slip and returns what happened. The handler is a
suspendfunction and runs on the main thread, so it can wait on your own slip code. - The chat shows the visitor a short note in their language, such as "Added to slip".
chat.onAddToSlip = { selection ->
withTimeout(9_000) {
if (mySlip.contains(selection.matchOddsId)) SlipResult.Duplicate
else {
mySlip.add(selection.matchOddsId)
SlipResult.Added()
}
}
}You have 10 seconds to answer. No answer in time counts as a failure: the visitor sees "Couldn't add
to slip. Try again." We don't cancel your handler at 10 seconds, so give it its own timeout under 10
seconds, as above. When that withTimeout fires, or your handler throws, the wrapper answers
Rejected(RejectReason.UNSUPPORTED) for you.
The button is always shown on mobile. The default handler rejects every selection with
UNSUPPORTED, so set yours before visitors can open the chat.
What the wrapper sends: Selection
| Field | Type | Meaning |
|---|---|---|
matchOddsId | Long | Your sportsbook's id for the selection. Look it up in your slip. |
matchId | Long | Your sportsbook's id for the match. |
oddsDecimal | Double | The price the visitor saw, as a decimal. |
sport | Sport? | null (or FOOTBALL) means football. |
tour | String? | Tennis only: the tour the match id belongs to. |
odds | SlipOdds? | The same price in your account's odds format (not the visitor's own choice): format (e.g. "american") and text (e.g. "+150"). |
quotedAtUtc | String? | ISO time when that price was last confirmed. |
conversationId, insightId | String? | Which chat and which card the tap came from. |
display | SlipDisplay? | The pick in words, for showing only: home, away, kickoffUtc, market, marketLabel, selection, line, player, each a String?. Never price or settle a bet from these. |
Every field after tour is optional: one the page leaves out or sends with the wrong type is null
and never stops the selection reaching you. A selection that lacks matchOddsId, matchId or
oddsDecimal never reaches your handler; the wrapper answers unsupported for you.
What you return: SlipResult
| Return | When | The visitor sees (English) |
|---|---|---|
SlipResult. or null | The selection is in the slip. Added also takes a SlipSummary(; it is accepted but not shown today. | Added to slip |
SlipResult. | It was already in the slip. | Already in your slip |
SlipResult. | The price moved and you added it at the new price. newOdds is the new price as text. | Added at 2.10 (was 1.95) |
SlipResult. | The price moved and you did not add it. | Price moved to 2.10 (was 1.95). Tap to add. |
SlipResult. | You did not add it. reason is a RejectReason below. | See below |
RejectReason | Meaning | The visitor sees (English) |
|---|---|---|
LOGIN_REQUIRED | The visitor must sign in first. | Sign in to add to your slip |
SUSPENDED | The market is suspended. | Market suspended |
CLOSED | The market or match is closed, e.g. it has started. | Your message, else "This selection can't be added." |
NOT_FOUND, LIMIT, UNSUPPORTED | You don't know this selection; the slip is full or a limit is reached; you don't take this kind of selection. | Your message, else "Couldn't add to slip. Try again." |
Other languages show the same notes, translated. message is your own text, shown as is: write it
in the visitor's language. It is ignored for LOGIN_REQUIRED and SUSPENDED.
Other sports. Football prices can be added once your handler is set. Basketball, American
football and tennis prices get the button only when slipSports lists that sport, so a handler that
only knows football never receives them:
slipSports = listOf(SlipSport.BASKETBALL, SlipSport.TENNIS)For these sports the prices come from our own data, so matchOddsId and matchId are our ids, not
your sportsbook's. Find the selection from display (teams, kick-off, market, selection and line)
and tour for tennis, and return Rejected(RejectReason.NOT_FOUND) when you cannot.
Telling the chat what happened next (optional). These calls help the chat track your slip. Calls made before the page is ready are kept and sent once it is.
| Call | When |
|---|---|
chat. | The visitor removed a selection from your slip. |
chat. | The visitor placed a bet. Pass every selection. Only the selections are required; a non-finite stake or totalOdds is left out. |
chat. | The visitor opened a match screen. matchId is a Long. |
SlipRef(matchOddsId: Long, sport: Sport? = null): pass the sport the Selection carried, and
leave it null for football.
8. The icon and teaser#
By default SensibleStatsLauncher draws our icon and teaser. Add it as the last child of a
FrameLayout that covers the screen. It shows only while chat.available is true, and it tells
the chat itself when the teaser is shown.
To draw them yourself, in your app's design, set launcher = false in the config (and leave out
SensibleStatsLauncher.kt if you like), then draw from the chat's state:
lifecycleScope.launch {
repeatOnLifecycle(Lifecycle.State.STARTED) {
combine(chat.available, chat.teaser) { available, teaser -> available to teaser }
.collect { (available, teaser) ->
myIcon.isVisible = available
if (teaser == null) myTeaser.hide() else {
myTeaser.show(teaser.text, teaser.asks, teaser.price)
chat.teaserShown()
}
}
}
}
myIcon.setOnClickListener { chat.open() }State you can read (all StateFlow):
| Property | Type | Meaning |
|---|---|---|
chat. | Boolean | The page is ready and the chat can open. Show your icon only while it is true. |
chat. | Teaser? | The current teaser, or null. |
chat. | Boolean | The chat sheet is showing. |
chat. | UnavailableReason? | Why the chat cannot start (section 11), or null. |
chat. | LauncherLabels? | launcher and dismiss: screen-reader labels for your icon and your teaser's close button, in the visitor's language. null until the page sends them; use your own text until then. |
chat. | Theme? | LIGHT or DARK: the theme the chat is drawn in, including a theme the visitor picked in the chat. Use it to colour your launcher. null until the page sends it. |
chat. | SensibleStatsConfig | The config in use (changes on reload). |
chat.onTeaser receives the same teaser as chat.teaser, on every change. It is not called for
the empty start.
Teaser
| Field | Type | Meaning |
|---|---|---|
text | String? | The greeting line. |
asks | List<Teaser. | Suggested questions, each Ask(. Show label; pass index to tapAsk. |
cta | String? | A button label, e.g. "Build a bet". |
price | TeaserPrice? | One price: matchOddsId: Long, marketLabel (the market's name), label (the selection's name), odds (the price as text, in the visitor's format). |
Call these when the visitor acts on your teaser:
| Call | When | What the chat does |
|---|---|---|
chat. | The visitor tapped your icon. | Opens the chat sheet. |
chat. | You showed the teaser. | Counts it as seen, once per teaser. |
chat. | The visitor tapped the teaser text. | Opens the chat. |
chat. | The visitor tapped a suggested question. | Opens the chat and asks it. |
chat. | The visitor tapped the button. | Opens the chat on it. |
chat. | The visitor tapped the price. | Checks the price again, then calls your onAddToSlip. The sheet stays closed. A suspend fun returning PriceResult? (below). |
chat. | The visitor closed the teaser. | Clears it; teaser becomes null. |
Opening the chat in any way clears the teaser.
lifecycleScope.launch {
val result = chat.tapPrice()
myTeaser.showNote(result?.text)
}PriceResult(matchOddsId: Long, outcome: PriceOutcome, text: String?). text is the note to show
under the price, already in the visitor's language, or null. tapPrice() returns null when there
is nothing to answer: no price on screen, an earlier tap still waiting, the teaser replaced or
cleared, no answer within 15 seconds, a reload or destroy(). While a tap is waiting, show the price
disabled.
outcome is ADDED (the selection is in the slip: added, already there, or added at a new price),
GONE (the price is no longer offered), COOL_OFF (too many requests; try again shortly) or FAILED
(not added: your handler refused it or did not answer).
Make the price and the button real buttons for screen readers, at least 48 dp high, with the selection's label and the price read together.
9. Events for your analytics#
Every visitor action in the chat is passed to chat.onEvent as a JSONObject, so you can forward
it to your own analytics. The chat does not check consent; gate your own sending on it.
Every event carries name, at (epoch ms, when it happened), operatorId and widgetVersion, and
when known language, conversationId, operatorUserId and page. A ? marks a field that can be
absent.
| Event | Fields |
|---|---|
widget_open | source? (launcher, bubble, teaser, host, popup), first? |
widget_close | method (button, escape, host for your close(), native, back), tab, answering, openMs? |
bubble_shown, bubble_click, bubble_dismiss | none |
bubble_ask_click | position |
tab_change | from, to, source? (bar, link, auto) |
question_asked | turnId, source, length, text? (only with eventText), method?, chipId?, position?, actionRef?, retryOf?, matchId? |
answer_received | turnId, conversationId, latencyMs, cardTypes, firstByteMs? |
answer_failed | turnId, code |
answer_stopped | turnId |
add_to_slip_click | matchOddsId, matchId, odds, market?, sport?, factKey?, surface?, turnId? |
add_to_slip_result | the same fields, plus outcome |
pin_click | action (add, remove), target (match, market), matchId?, market?, sport?, surface?, turnId? |
combo_add_click | surface (builder, chat), sport, legs, total, turnId? |
combo_variant_click | surface, sport, legs, total, variant |
combo_swap_click | surface, sport, legs, total |
all_markets_click | matchId, market?, surface |
dashboard_tile_click | entityType, entityId |
sport_switch | sport |
new_conversation | none |
favourite_change | kind, id, outcome, sport?, surface?, before? |
add_to_slip_result.outcome is added, duplicate, price_changed, timeout or the reject reason
you returned, in lower case (login_required, suspended, closed, not_found, limit,
unsupported). timeout covers any failed add, not only a late one. odds in events is always a
decimal number.
tab, from and to are one of chat, live, matches, builder, following, trends,
games, fixtures, standings, squad, records. question_asked.source is one of typed,
starter, action, tile, preset, live_fact, bubble_ask, retry, match_sheet.
10. Colours#
Each theme has four colours. A colour you leave out keeps ours. The dark theme reads only the dark colours, never the light ones.
| Colour | Used for | Light default | Dark default |
|---|---|---|---|
accent | Your brand colour: links, highlights and the teaser's suggested questions. | #17936a | #37c891 |
cta | Price and "Add to slip" buttons, and the teaser's price and button. | #f5a623 | #ffb638 |
surface | Backgrounds: the chat, the icon and the teaser. | #ffffff | #141b24 |
ink | Text, and the chat mark on our icon. | #14181d | #e8edf2 |
Colours must be hex: #rgb, #rrggbb or #rrggbbaa. Any other value is dropped, from the chat and
from the launcher alike, and the default applies (a debug build logs that it was dropped).
Set surface and ink together: the teaser, lines and faint text are then mixed from them.
colors = Colors(
light = ThemeColors(accent = "#0b5fff", cta = "#ffcc00"),
dark = ThemeColors(accent = "#5c93ff", cta = "#ffd633", surface = "#0d1117", ink = "#f0f3f6"),
)Our launcher picks the theme the chat last reported (chat.pageTheme); until then it uses theme
from your config, and AUTO follows the device's dark mode. Text on the price and button is always
a fixed dark colour, so choose a light enough cta.
11. When the chat cannot start#
chat.available turns true when the page loads, and back to false if our server then refuses
the chat, so the icon can show for a moment before it hides. When the page reports one of the
reasons below, the wrapper closes the chat sheet (isOpen is already false when your callback
runs), hides the launcher, clears the teaser, sets chat.unavailableReason and calls
chat.onUnavailable(reason). It does this every time the page reports it. A reason this version of
the wrapper does not know only hides the launcher.
UnavailableReason | Cause | Fix |
|---|---|---|
NO_USER | operatorUserId is blank, for example after sign-out. | Sign the visitor in, then reload with their id (section 5). |
MOBILE_DISABLED | Mobile is not switched on for your account. | Ask your SensibleStats contact to switch mobile on for your account. |
WIDGET_DISABLED | The widget is off for your account, or the operator id is not one we know. | Check the id. If it is right, ask your contact to switch the widget on. |
AUTH_FAILED | The public key is wrong or empty, or the operator id is empty. | Check both values. |
unavailableReason goes back to null when the page becomes ready, and on reload.
Errors the wrapper throws:
| Error | Cause |
|---|---|
IllegalArgumentException: baseUrl must be an https URL with a host | baseUrl is not https, or has no host. |
IllegalArgumentException: reload() keeps the gateway origin | reload was given a different baseUrl origin. |
12. Platform notes#
- Threads.
open,close,reload,setPage,destroy, the slip calls and the teaser calls are safe from any thread: the wrapper moves them to the main thread and keeps them in the order you made them. Callbind,unbindandonBackPressedon the main thread. - The chat sheet. The chat opens in a full-height Material bottom sheet over the bound activity.
It pads itself for the system bars and the keyboard.
open()does nothing while no activity is bound or after the activity has saved its state. - Back button. While the sheet is open, back first steps back inside the chat (for example, from a match to the list). When the chat has nowhere to step back to, or does not answer within 300 ms, the sheet closes. You don't need to handle back yourself.
- Closing. The sheet closes when the visitor swipes it down, taps the chat's close button,
presses back as above, or you call
chat.close(). - Links. The WebView stays on
https://your-widget-host. Every other link opens outside your app with anACTION_VIEWintent: web pages in the browser,mailto:andtel:in the mail and phone apps. If no app can open it, nothing happens. - Renderer crash. If the system kills the WebView's renderer, the wrapper replaces the WebView and reloads the chat; your app does not crash. If the sheet was open it reopens once the page is ready. A second crash before the visitor opens the chat again closes the sheet instead.
- Load failure. If the chat page fails to load, the wrapper retries once.
- WebView settings. JavaScript and DOM storage are on, so the chat's preferences and
conversation survive restarts. File and content access are off, and mixed content is blocked.
Messages are accepted only from
https://your-widget-host. Debug builds turn on WebView debugging. - The WebView object.
chat.webViewis replaced after a renderer crash; don't keep a reference to it.
13. Reference#
SensibleStatsChat(context, config). After destroy(), don't call it again.
| Method | Returns | What it does |
|---|---|---|
bind( | nothing | Section 3. |
unbind( | Boolean | Section 3. |
open(), close() | nothing | Opens or closes the chat sheet. |
reload( | nothing | Loads the chat again with a new config (section 5). |
setPage( | nothing | Sets the screen (section 6); null clears it. |
destroy() | nothing | Stops the chat and destroys the WebView. |
slipRemoved(, betPlaced(, matchOpened( | nothing | Section 7. |
teaserShown(), tapTeaser(), tapAsk(, tapCta(), dismissTeaser() | nothing | Section 8. |
tapPrice() | suspend, PriceResult? | Section 8. |
onBackPressed() | Boolean | Used by the chat sheet for the back button. false when the sheet is not open. You don't need to call it. |
| Property | Type | Section |
|---|---|---|
onAddToSlip | suspend ( | 7 |
onTeaser | ( | 8 |
onUnavailable | ( | 11 |
onEvent | ( | 9 |
onBridgeMessage | ( | 4 |
available, teaser, isOpen, unavailableReason, labels, pageTheme, config | StateFlow | 8 |
WRAPPER_VERSION | String, companion constant | 3 |