Android reference (TryYourSize for Kotlin)
minSdk 24, Jetpack Compose and Views. The window needs an androidx ComponentActivity (for example AppCompatActivity). Register your app for the key in Studio as android-app://<package> (test mode today; live mode for apps is coming soon).
Install
Section titled “Install”dependencies { implementation("com.tryyoursize:tryyoursize-android:0.1.0") }Initialize
Section titled “Initialize”val tys = TryYourSize(context, "pk_test_…") // a secret key throwsimport TryYourSize
let tys = try TryYourSize(publishableKey: "pk_test_…") // a secret key throwsError codes: Mobile SDK errors.
Client
Section titled “Client”constructor |
Creates the client for your publishable key. |
Configuration |
TryYourSize.Configuration |
recommendation() |
The shopper’s recommended size for a product, in your size labels. |
getRecommendation() |
The same, with a callback (Java). |
onRecommendation() |
Calls handler now (once known) and on every change: signing in, a new body, a simulation finishing. |
on (events) |
Window events: Ready, Open, Close, Size, LoadError. |
present() |
Opens the measuring / try-on window for a product, full screen over activity. |
appearance |
Live restyle (e.g. |
appOrigin |
android-app://<package>: what the store registers as an allowed origin. |
Size guide button
Section titled “Size guide button”SizeGuide |
The “Size guide” button: “Size guide” → “Calculating your size…” → “Your size: M”. |
SizeGuideView |
The same button as an Android View: set client and product. |
Recommendation |
The shopper’s recommended size for one product, in the store’s own size labels. |
Appearance |
Colours (ARGB ints), font and corner radius for the button and the window. |
TryYourSizeException |
Every error the SDK raises: a stable code, a message and a doc link (like the web SDK). |
Was this page helpful?
Thank you. We read every answer.