The mobile SDKs are available on request. Email support@grona.ai to get access.
Android API reference
This page lists the public API of ai.grona:grona-core:0.1.2. Every type is in the package ai.grona.sdk. Methods on Grona and the companion factories are annotated @JvmStatic, so Java callers use them as static methods.
The SDK never throws into your app, with one exception: GronaOptions.Builder.build() throws IllegalArgumentException on invalid input.
As above, for keyed placements such as cart_line, where key is the line’s product id.
fun activeTreatments(): List<GronaTreatment>
Treatments currently shown to this shopper, each with the grant token your order backend must check.
fun refresh()
Asks the activation source and requests a configuration refresh, which can be skipped when the SDK refreshed very recently or a recent check failed. No completion signal.
fun refresh(listener: GronaRefreshListener)
Refreshes now and calls listener once on the main thread when done, also on failures and before init. A skipped refresh also calls it, so the call does not mean a new configuration arrived.
fun handleLink(uri: Uri): Boolean
Handles <scheme>://grona-preview?.... Returns true when the link was Grona’s, whether or not it was accepted.
fun reset()
Logout or erasure: new install id, and the event queue, customer, profile, grants, basket snapshot and previews cleared.
fun openDebugView(context: Context)
Opens the debug view when the grona-debug artifact is present and the app is debuggable. Otherwise does nothing.
Options for Grona.init. Build with GronaOptions.Builder. build() throws on invalid input. Each builder method returns the Builder. Every option is also readable as a property of the same name on GronaOptions, except that keys are readable as the maps configKeys and grantKeys.
Builder member
Description
Builder(workspaceKey: String)
The workspace key, a public identifier, not a secret. Must match [A-Za-z0-9._:-]{1,128}.
fun configUrl(url: String)
The configuration address Grona gives you (https). Without it the SDK runs on the bundled copy.
fun bundledConfigAsset(path: String)
Asset path of the bundled configuration file Grona gives you, used at launch and offline.
fun configKey(kid: String, publicKeySpki: String)
One of Grona’s public keys for your configuration: key id and key, exactly as Grona gives them. Add the current and the next. At least one is required.
fun grantKey(kid: String, publicKeySpki: String)
One of Grona’s public keys for grants, set the same way as configKey.
fun eventsUrl(url: String)
The events address Grona gives you (https). Without it the SDK sends no events and keeps no event queue. Debuggable builds keep recent events in memory for the debug view.
fun previewUrl(url: String)
The preview address Grona gives you (https). Without it preview links only clear previews.
fun activationSource(source: GronaActivationSource)
Source of on and off answers from an external campaign system.
Highest quantity one action may add, 1 to 20. Default 5.
fun maxAddLines(max: Int)
Most lines one action may add, 1 to 20. Default 5.
fun sendPreConsentEvents(enabled: Boolean)
Send events buffered before consent once it is granted. Default false.
fun demoMode(enabled: Boolean)
Demo only, never in production. Takes effect only when Grona also switches demo mode on for your demo setup. Default false.
fun build(): GronaOptions
Validates and builds. Throws IllegalArgumentException for an invalid workspace key, a URL that is not https, no configKey, or add caps outside 1 to 20.
A place in your layout where Grona shows native components: banner, progress, offer and message. With nothing to show it stays laid out at zero height. Never set it GONE or INVISIBLE.
Member
Description
var placement: String
The placement. Usually set in XML with app:gronaPlacement. Set it before screen.
var screen: GronaScreen?
Starts the slot; audience rules read it. An equal value continues the visit; null ends it.
Commerce events your app forwards from its analytics layer. Money is in minor units; no search text, no full baskets. Exception: on keyed placements such as cart_line, campaign events carry the line’s product id as their key, for every shopper. So while a cart_line campaign is live, the product ids of the cart lines bound to it leave the device.
Member
Description
fun viewItem(productId: String, priceMinor: Long): GronaEvent
A product view.
fun addToCart(productId: String, qty: Int, priceMinor: Long): GronaEvent
A cart add.
fun removeFromCart(productId: String, qty: Int): GronaEvent
A cart removal.
fun beginCheckout(totalMinor: Long): GronaEvent
Checkout started.
fun purchase(orderId: String, totalMinor: Long, productIds: List<String>, treatments: List<GronaTreatment>): GronaEvent
A confirmed order. productIds is the whole order; the SDK keeps only those Grona campaigns showed or added.
An offer with a reward. Display state only: your order backend applies it only after checking token.
Member
Description
val campaignId: String
The campaign.
val variantId: String
The variant.
val placement: String
Where it was shown.
val type: String
The treatment type.
val valueMilli: Long
Value in thousandths, so 10000 is 10 (10% off with percent_off).
val token: String?
The grant token from Grona; null when an offer shows without a grant in demo mode. A real backend ignores a treatment without a token: no treatment, and the order still goes through.
val isDemo: Boolean
true when an offer shows without a grant in demo mode.
val productId: String, val qty: Int; secondary constructor GronaLine(productId: String) with qty 1
One product and quantity in an action.
class GronaSource
val placement: String, val campaignId: String, val variantId: String
Which campaign and variant an action came from.
class GronaRoute
val type: String, val id: String?
A typed destination your app resolves itself. Grona never passes raw links.
HOME, PRODUCT, CATEGORY, CART, CHECKOUT, DEALS
Route type constants: "home", "product", "category", "cart", "checkout", "deals". Unknown types may arrive from newer configurations; return false from GronaHost.navigate for them.
Product facts from your app. Money is in minor units. Each builder value is also readable as a property: productId, name, priceMinor, wasPriceMinor, imageUri, inStock.
Visual tokens so SDK components match your app. Each value is also readable as a property: fontRegular, fontBold, primary, onPrimary, accent, surface, text, mutedText, cornerRadiusDp.
Member
Default
fun fonts(regular: Typeface?, bold: Typeface?): Builder
Receives SDK diagnostics. Silent by default; never given customer ids, baskets, tokens or keys.
GronaLogger.NONE
The silent default.
fun interface GronaActivationSource
fun activeExternalIds(): Set<String>?
On and off answers from an external campaign system. Called on a Grona background thread; may block up to 10 seconds, and a slower answer counts as unknown. null when unknown. Activation can only switch campaigns off.
fun interface GronaGrantSource
fun fetchGrants(customerId: String): List<String>?
Fetches grants from your backend, which asks Grona’s server for them. Called on a Grona background thread; may block up to 10 seconds. Returns the grant strings exactly as received, or null on failure.