Initialisation
After installing MealzUIKit, start the library once at app launch (for example in AppDelegate / @main app init). On iOS, Kotlin object APIs are accessed via .shared (for example SdkConfiguration.shared).
Start the Library
import MealzUIKit
SdkConfiguration.shared.start(
supplierKey: WEB_SUPPLIER_KEY, // base64-encoded web key
context: SdkContext(),
environment: .prod // or .dev
)
MealzUIKit expects the web supplier key format (base64 JSON including supplierId, origin, domain, noSupplier, …) — the same key family used by Mealz SSR. If you do not already have a web/SSR key, Mealz will provide one for your integration.
User
setUser and getCurrentUser are suspending — call them from a coroutine (Kotlin) or an async context that can await Kotlin suspend functions (Swift). Call after start, and again whenever auth changes.
Defaults
Out of the box (after start, no user calls):
- Authless mode is on —
isAuthlessModeEnabled()istrueuntil you calldisableAuthlessMode(). - Identity is a guest —
getCurrentUser()isUser.Authlesswith an id from/v2/generate-authless-token(fetched on first need). Guests can browse and fill a Mealz basket.
Call disableAuthlessMode() only if shoppers must log in before basket actions. While authless mode is off and the shopper is not logged in, adding to the Mealz basket (and similar actions) triggers your screen’s redirectToLogIn callback so you can open your login flow.
SdkConfiguration.shared.isAuthlessModeEnabled() // true by default
SdkConfiguration.shared.enableAuthlessMode()
SdkConfiguration.shared.disableAuthlessMode()
Nothing to change for user auth — keep the default guest behaviour. Do not call setUser("…"). See No Supplier.
Log in
When the shopper logs into your app:
// suspend — call via your async / coroutine bridge
SdkConfiguration.shared.setUser(userId: "user-123")
If the previous identity was User.Authless and authless mode is on, Mealz may merge the guest basket into the logged-in basket (only when a store is already selected; best-effort — failures do not block setUser). See Login and logout.
Log out
On logout, fall back to a guest identity:
SdkConfiguration.shared.setUser(userId: nil)
- Leaving
User.Authenticatedswitches toUser.Authlesswith a new authless id from/v2/generate-authless-token. - Already
User.Authlessreuses the stored id (no SSR call). - Does not change the authless-mode flag. With mode still on (default), the shopper can fill a guest basket again; if you had disabled authless mode, basket actions keep calling
redirectToLogInuntil you re-enable it orsetUser("…").
Session (optional)
Call before any SSR/WebView use if you need a fixed session id:
SdkConfiguration.shared.forceSessionIdTo(uuid: "00000000-0000-0000-0000-000000000000")
let sessionId = SdkConfiguration.shared.getCurrentSessionId()
Store
Retailer mode — set the shopper's store with your POS / external id:
SdkConfiguration.shared.setSelectedStoreWithExternalId(externalStoreId: "store-ext-42")No Supplier mode — do not call setUser("…") and do not set a store in the normal flow. Leave authless defaults; store (and retailer) selection is handled by the Supplier Selector flow: Mealz opens it automatically, or other No Supplier components request it when a store is required.
// Only for a specific advanced need — prefer letting SupplierSelector drive this
SdkConfiguration.shared.setSelectedStoreWithMealzId(mealzStoreId: "mealz-store-id")
Using the wrong store API for the key mode throws (external ids are retailer-only; Mealz ids are No Supplier-only).
First Integration Checklist
Retailer vs No Supplier
You do not pick the mode in code. It is encoded in the supplier key Mealz gives you (noSupplier flag). Use the same SdkConfiguration.shared.start(...) flow either way; APIs that only apply to one mode (retailer basket sync vs No Supplier helpers) simply become relevant depending on that key.
For No Supplier UI helpers, see No Supplier.
Retailer Mode
- Call
SdkConfiguration.shared.start(...)once at app launch. - When the shopper logs in, call
setUser("…"); on logout, callsetUser(null)— both are suspend. See User above. - Set the store with
setSelectedStoreWithExternalId. - Register the basket synchronizer after
startand before any Mealz screen — see Basket Synchronization. - Present a first screen (usually Catalog) — see Catalog under Features.
- Optional: register CSS manifests — Styling (defaults already work).
No Supplier Mode
- Call
SdkConfiguration.shared.start(...)with your No Supplier web key (mode is in the key). - Do not identify the shopper (
setUser("…")) and do not select a store — leave authless defaults and let Supplier Selector drive retailer/store picking. - Present Catalog and/or No Supplier helpers (pricing, add-to-cart CTA) — see Features.
- Optional: register
BasketCountNotifierlisteners for recipe / product badges — see No Supplier. - Optional: register CSS manifests — Styling.
Next Steps
- Basket Synchronization (retailer mode)
- Feature screens under Features
- Optional branding: Styling
Optional Configuration
Language
Default: Language.FR (fr).
SdkConfiguration.shared.setSelectedLanguage(language: .fr) // .en, …
SdkConfiguration.shared.getCurrentLanguage()Sets the locale used for SSR content (Language-id). Values map to ISO language codes (fr, en, …). See SSR internationalization for custom label files.
Profiling
Default: enabled.
SdkConfiguration.shared.enableProfiling()
SdkConfiguration.shared.disableProfiling()Controls personalization across Mealz features (recommendations, tailored catalog content, …). Mirror the shopper's consent: if profiling / cookies are refused, call disableProfiling(). This maps to the SSR profiling header (true / false).
Custom Labels
Default: disabled.
SdkConfiguration.shared.enableCustomLabels()
SdkConfiguration.shared.disableCustomLabels()When enabled, SSR uses your custom i18n override files (if configured with Mealz) instead of the default Mealz copy. Keep this off unless you have custom label packs. Details: SSR internationalization.
Debug Mode
Default: disabled.
SdkConfiguration.shared.enableDebugMode()
SdkConfiguration.shared.disableDebugMode()Developer-only. Makes the Mealz WKWebView inspectable in Safari. Do not ship with this enabled in production.
- On the iPhone: Settings → Safari → Advanced → Web Inspector → On.
- Call
SdkConfiguration.shared.enableDebugMode()afterstart. - On a Mac with the device connected (or simulator): Safari → Develop → your device / simulator → pick the Mealz WKWebView page.