Skip to the guide

Need help? Your SensibleStats contact can answer questions about any guide and send the three values. Write to solutions@sensiblestats.com.

Highlighted values such as YOUR_PUBLIC_KEY are placeholders. Replace them with the values we send you.

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:

  1. Get your operator id, public key, widget origin and the wrapper files from your SensibleStats contact.
  2. Ask your contact to switch mobile on for your account.
  3. Add the files, create the chat in a ViewModel with the signed-in visitor's id, and bind your activity.
  4. Set onAddToSlip, then test an add, a duplicate and a reject.
  5. 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/m in 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.
  • matchOddsId is your sportsbook's own id for one selection: one outcome of one market.
  • operatorUserId is 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 usExampleWhat it is
Operator idYOUR_OPERATOR_IDYour account in our system. Part of every request.
Public keyYOUR_PUBLIC_KEYIdentifies your widget. Safe to ship inside your app.
Widget originhttps://your-widget-hostThe address the chat page loads from. Goes in baseUrl.
To usWhat it is
Switch on mobileAsk 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:

RequirementValue
minSdk24 or higher.
LanguageKotlin, Java 17 target.
ActivityA FragmentActivity (for example AppCompatActivity) that implements ChatOwner.
Permissionandroid.permission.INTERNET in AndroidManifest.xml.
Build featurebuildConfig = true: the wrapper reads BuildConfig.DEBUG.

Dependencies the wrapper files use:

Kotlin
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:

FileNeededWhat it holds
SensibleStatsConfig.ktYesSensibleStatsConfig and the types it uses.
SensibleStatsChat.ktYesSensibleStatsChat (the WebView, the bridge and the chat sheet), and the slip and teaser types.
SensibleStatsLauncher.ktNoSensibleStatsLauncher, our icon and teaser. Leave it out if you draw your own (section 8).
themes.xml styles ChatSheetDialog and ChatSheetStyleYesThe chat sheet's style, built on Material 3 parents. Copy both styles into your own res/values/themes.xml.

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:

Kotlin
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:

Kotlin
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.

CallWhenWhat it does
SensibleStatsChat(context, config)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.bind(activity)In every onCreate.Lets the chat open its sheet over this activity. open() does nothing until an activity is bound.
chat.unbind(activity)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.destroy()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#

FieldTypeWhat it does
baseUrlStringhttps://your-widget-host. Must be https with a host. Only scheme, host and port are used; any path is replaced.
operatorIdStringYour operator id.
publicKeyStringYour public key.
userContextUserContext(operatorUserId: String)The signed-in visitor. See section 5.

An empty operatorId or publicKey makes the chat report AUTH_FAILED.

Visitor, language and time#

FieldTypeDefaultWhat it does
localeString?, language tag, e.g. en-GB, tryour account's default language (English unless you asked for another)The language of the chat and its answers.
timeZoneString?, IANA zone, e.g. Europe/Istanbulthe device's zoneKick-off times and day names follow this zone.
oddsFormatOddsFormat?: DECIMAL, AMERICAN, FRACTIONALdecimalHow prices are written. A visitor who picks a format in the chat's settings keeps their choice.

Greeting and page#

FieldTypeDefaultWhat it does
greetingMessageString?nullThe 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.
pagePageContext?nullThe screen the visitor is on, so the greeting can lead with it. Section 6.
placeholderString?localizedText in the empty question box.
startersList<String>?nullSuggested questions shown in an empty chat. Don't use | inside a question: the list is sent joined by |.

Look#

FieldTypeDefaultWhat it does
themeTheme: LIGHT, DARK, AUTOAUTOAUTO follows the device's dark mode. A visitor who picks a theme in the chat keeps their choice.
colorsColors?our coloursColors(light = ThemeColors(...), dark = ThemeColors(...)). Section 10.
logoUrlString?, https or data: URLour markYour square logo, shown on the icon and in the chat header. A data: URL must be base64.
headerTitleString?SensibleStatsThe chat's title.
radiusDouble?16Corner radius of the chat, in px. Only finite values from 0 are sent.
pinIconPinIcon?: PIN, STAR, BOOKMARKpinThe icon visitors tap to follow a match or price.
launcherBooleantruefalse hides our icon and teaser so you draw your own (section 8).
positionPosition: LEFT, RIGHTRIGHTWhich bottom corner the icon sits in.
offsetOffset(x: Int = 20, y: Int = 20)20, 20Distance in dp from the side and from the bottom, on top of the system bars.
launcherLabelString?"Chat with SensibleStats", localizedThe 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.

SettingTypeWhat it does
chat.onAddToSlipsuspend (Selection) -> SlipResult?Adds a price to your bet slip. Section 7.
config.slipSportsList<SlipSport>?: BASKETBALL, AMERICANFOOTBALL, TENNISThe sports your onAddToSlip accepts besides football. Section 7.
chat.onTeaser(Teaser?) -> UnitGives you the teaser to draw yourself. Section 8.
chat.onUnavailable(UnavailableReason) -> UnitTells you the chat cannot start. Section 11.
chat.onEvent(JSONObject) -> UnitEvery chat event, for your own analytics. Section 9.
config.eventTextBoolean, default falseAdds the visitor's question text to question_asked events. Answer text is never sent.
chat.onBridgeMessage((BridgeDirection, String) -> Unit)?, default nullFor 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:

Kotlin
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:

Kotlin
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.

Kotlin
page = PageContext(sport = Sport.FOOTBALL, kind = PageKind.MATCH, matchId = PageId.of(19432556L))
FieldTypeMeaning
sportSport: FOOTBALL, BASKETBALL, AMERICANFOOTBALL, TENNISRequired.
kindPageKind?: SECTION, COMPETITION, MATCHA sport's front page, a competition page, or a match page.
matchIdPageId?Your sportsbook's id for the match on a match screen.
competitionIdPageId?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:

  1. The visitor taps "Add to slip" under a price.
  2. The wrapper calls chat.onAddToSlip(selection). selection.matchOddsId is your sportsbook's own id for that selection, so you can look it up directly.
  3. Your code adds that selection to your slip and returns what happened. The handler is a suspend function and runs on the main thread, so it can wait on your own slip code.
  4. The chat shows the visitor a short note in their language, such as "Added to slip".
Kotlin
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

FieldTypeMeaning
matchOddsIdLongYour sportsbook's id for the selection. Look it up in your slip.
matchIdLongYour sportsbook's id for the match.
oddsDecimalDoubleThe price the visitor saw, as a decimal.
sportSport?null (or FOOTBALL) means football.
tourString?Tennis only: the tour the match id belongs to.
oddsSlipOdds?The same price in your account's odds format (not the visitor's own choice): format (e.g. "american") and text (e.g. "+150").
quotedAtUtcString?ISO time when that price was last confirmed.
conversationId, insightIdString?Which chat and which card the tap came from.
displaySlipDisplay?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

ReturnWhenThe visitor sees (English)
SlipResult.Added() or nullThe selection is in the slip. Added also takes a SlipSummary(selectionCount, totalOddsDecimal); it is accepted but not shown today.Added to slip
SlipResult.DuplicateIt was already in the slip.Already in your slip
SlipResult.PriceChanged(newOdds = "2.10", accepted = true)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.PriceChanged(newOdds = "2.10", accepted = false)The price moved and you did not add it.Price moved to 2.10 (was 1.95). Tap to add.
SlipResult.Rejected(reason, message = null)You did not add it. reason is a RejectReason below.See below
RejectReasonMeaningThe visitor sees (English)
LOGIN_REQUIREDThe visitor must sign in first.Sign in to add to your slip
SUSPENDEDThe market is suspended.Market suspended
CLOSEDThe market or match is closed, e.g. it has started.Your message, else "This selection can't be added."
NOT_FOUND, LIMIT, UNSUPPORTEDYou 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:

Kotlin
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.

CallWhen
chat.slipRemoved(SlipRef(matchOddsId, sport))The visitor removed a selection from your slip.
chat.betPlaced(listOf(SlipRef(matchOddsId, sport)), stake = 10.0, currency = "EUR", betId = "B123", betType = "single", totalOdds = 2.5)The visitor placed a bet. Pass every selection. Only the selections are required; a non-finite stake or totalOdds is left out.
chat.matchOpened(matchId)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:

Kotlin
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):

PropertyTypeMeaning
chat.availableBooleanThe page is ready and the chat can open. Show your icon only while it is true.
chat.teaserTeaser?The current teaser, or null.
chat.isOpenBooleanThe chat sheet is showing.
chat.unavailableReasonUnavailableReason?Why the chat cannot start (section 11), or null.
chat.labelsLauncherLabels?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.pageThemeTheme?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.configSensibleStatsConfigThe 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

FieldTypeMeaning
textString?The greeting line.
asksList<Teaser.Ask>Suggested questions, each Ask(index: Int, label: String). Show label; pass index to tapAsk.
ctaString?A button label, e.g. "Build a bet".
priceTeaserPrice?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:

CallWhenWhat the chat does
chat.open()The visitor tapped your icon.Opens the chat sheet.
chat.teaserShown()You showed the teaser.Counts it as seen, once per teaser.
chat.tapTeaser()The visitor tapped the teaser text.Opens the chat.
chat.tapAsk(index)The visitor tapped a suggested question.Opens the chat and asks it.
chat.tapCta()The visitor tapped the button.Opens the chat on it.
chat.tapPrice()The visitor tapped the price.Checks the price again, then calls your onAddToSlip. The sheet stays closed. A suspend fun returning PriceResult? (below).
chat.dismissTeaser()The visitor closed the teaser.Clears it; teaser becomes null.

Opening the chat in any way clears the teaser.

Kotlin
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.

EventFields
widget_opensource? (launcher, bubble, teaser, host, popup), first?
widget_closemethod (button, escape, host for your close(), native, back), tab, answering, openMs?
bubble_shown, bubble_click, bubble_dismissnone
bubble_ask_clickposition
tab_changefrom, to, source? (bar, link, auto)
question_askedturnId, source, length, text? (only with eventText), method?, chipId?, position?, actionRef?, retryOf?, matchId?
answer_receivedturnId, conversationId, latencyMs, cardTypes, firstByteMs?
answer_failedturnId, code
answer_stoppedturnId
add_to_slip_clickmatchOddsId, matchId, odds, market?, sport?, factKey?, surface?, turnId?
add_to_slip_resultthe same fields, plus outcome
pin_clickaction (add, remove), target (match, market), matchId?, market?, sport?, surface?, turnId?
combo_add_clicksurface (builder, chat), sport, legs, total, turnId?
combo_variant_clicksurface, sport, legs, total, variant
combo_swap_clicksurface, sport, legs, total
all_markets_clickmatchId, market?, surface
dashboard_tile_clickentityType, entityId
sport_switchsport
new_conversationnone
favourite_changekind, 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.

ColourUsed forLight defaultDark default
accentYour brand colour: links, highlights and the teaser's suggested questions.#17936a#37c891
ctaPrice and "Add to slip" buttons, and the teaser's price and button.#f5a623#ffb638
surfaceBackgrounds: the chat, the icon and the teaser.#ffffff#141b24
inkText, 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.

Kotlin
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.

UnavailableReasonCauseFix
NO_USERoperatorUserId is blank, for example after sign-out.Sign the visitor in, then reload with their id (section 5).
MOBILE_DISABLEDMobile is not switched on for your account.Ask your SensibleStats contact to switch mobile on for your account.
WIDGET_DISABLEDThe 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_FAILEDThe 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:

ErrorCause
IllegalArgumentException: baseUrl must be an https URL with a hostbaseUrl is not https, or has no host.
IllegalArgumentException: reload() keeps the gateway originreload 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. Call bind, unbind and onBackPressed on 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 an ACTION_VIEW intent: web pages in the browser, mailto: and tel: 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.webView is replaced after a renderer crash; don't keep a reference to it.

13. Reference#

SensibleStatsChat(context, config). After destroy(), don't call it again.

MethodReturnsWhat it does
bind(activity)nothingSection 3.
unbind(activity)BooleanSection 3.
open(), close()nothingOpens or closes the chat sheet.
reload(config)nothingLoads the chat again with a new config (section 5).
setPage(page)nothingSets the screen (section 6); null clears it.
destroy()nothingStops the chat and destroys the WebView.
slipRemoved(ref), betPlaced(selections, stake, currency, betId, betType, totalOdds), matchOpened(matchId)nothingSection 7.
teaserShown(), tapTeaser(), tapAsk(index), tapCta(), dismissTeaser()nothingSection 8.
tapPrice()suspend, PriceResult?Section 8.
onBackPressed()BooleanUsed by the chat sheet for the back button. false when the sheet is not open. You don't need to call it.
PropertyTypeSection
onAddToSlipsuspend (Selection) -> SlipResult?7
onTeaser(Teaser?) -> Unit8
onUnavailable(UnavailableReason) -> Unit11
onEvent(JSONObject) -> Unit9
onBridgeMessage((BridgeDirection, String) -> Unit)?4
available, teaser, isOpen, unavailableReason, labels, pageTheme, configStateFlow8
WRAPPER_VERSIONString, companion constant3