iOS reference (TryYourSize for Swift)
iOS 16+, Swift 5.9+, SwiftUI and UIKit. A client per publishable key, the native Size guide button, the shopper’s recommended size (sizes only), and our window in a sheet. Register your app for the key in Studio as ios-app://<bundle id> (test mode today; live mode for apps is coming soon).
Install
Section titled “Install”// File → Add Package Dependencies → the TryYourSize package, product "TryYourSize".// Package.swift:.product(name: "TryYourSize", package: "TryYourSize")pod 'TryYourSize'Initialize
Section titled “Initialize”import TryYourSize
let tys = try TryYourSize(publishableKey: "pk_test_…") // a secret key throwsval tys = TryYourSize(context, "pk_test_…") // a secret key throwsimport { configure } from "@tryyoursize/react-native";
await configure("pk_test_…"); // once, at startupimport 'package:tryyoursize/tryyoursize.dart';
final tys = await TryYourSize.create('pk_test_…');Error codes: Mobile SDK errors.
Client
Section titled “Client”init |
Creates the client for your publishable key. |
Configuration |
Options of the client. |
recommendation(for:) |
The shopper’s recommended size for a product, in your size labels. |
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, as a sheet over presenter (default: the app’s top-most view controller). |
appearance |
Live restyle (e.g. |
appOrigin |
ios-app://<bundle id>: 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”. |
SizeGuideButton |
The same button as a UIView. |
Recommendation |
The shopper’s recommended size for one product, in the store’s own size labels. |
Appearance |
Colours, font and corner radius for the button and the window. |
TryYourSizeError |
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.