Skip to main content
Version: 1.0

Initialisation

After installing MealzUIKit, start the library once at app launch (for example in Application.onCreate).

Start the Library​

import ai.mealz.uikit.config.SdkConfiguration
import ai.mealz.uikit.config.SdkContext
import ai.mealz.uikit.model.Environment

SdkConfiguration.start(
    supplierKey = WEB_SUPPLIER_KEY, // base64-encoded web key
    context = SdkContext(applicationContext),
    environment = Environment.PROD // or Environment.DEV
)
Supplier key

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() is true until you call disableAuthlessMode().
  • Identity is a guest — getCurrentUser() is User.Authless with 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.isAuthlessModeEnabled() // true by default
SdkConfiguration.enableAuthlessMode()
SdkConfiguration.disableAuthlessMode()
No Supplier

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:

SdkConfiguration.setUser("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.setUser(null)
  • Leaving User.Authenticated switches to User.Authless with a new authless id from /v2/generate-authless-token.
  • Already User.Authless reuses 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 redirectToLogIn until you re-enable it or setUser("…").

Session (optional)​

Call before any SSR/WebView use if you need a fixed session id:

SdkConfiguration.forceSessionIdTo("00000000-0000-0000-0000-000000000000")
val sessionId = SdkConfiguration.getCurrentSessionId()

Store​

Retailer mode — set the shopper's store with your POS / external id:

SdkConfiguration.setSelectedStoreWithExternalId("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.setSelectedStoreWithMealzId("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.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

  1. Call SdkConfiguration.start(...) once at app launch.
  2. When the shopper logs in, call setUser("…"); on logout, call setUser(null) — both are suspend. See User above.
  3. Set the store with setSelectedStoreWithExternalId.
  4. Register the basket synchronizer after start and before any Mealz screen — see Basket Synchronization.
  5. Present a first screen (usually Catalog) — see Catalog under Features.
  6. Optional: register CSS manifests — Styling (defaults already work).

No Supplier Mode

  1. Call SdkConfiguration.start(...) with your No Supplier web key (mode is in the key).
  2. Do not identify the shopper (setUser("…")) and do not select a store — leave authless defaults and let Supplier Selector drive retailer/store picking.
  3. Present Catalog and/or No Supplier helpers (pricing, add-to-cart CTA) — see Features.
  4. Optional: register BasketCountNotifier listeners for recipe / product badges — see No Supplier.
  5. Optional: register CSS manifests — Styling.

Next Steps​

  1. Basket Synchronization (retailer mode)
  2. Feature screens under Features
  3. Optional branding: Styling

Optional Configuration​

Language

Default: Language.FR (fr).

SdkConfiguration.setSelectedLanguage(Language.FR) // Language.EN, …
SdkConfiguration.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.enableProfiling()
SdkConfiguration.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.enableCustomLabels()
SdkConfiguration.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.enableDebugMode()
SdkConfiguration.disableDebugMode()

Developer-only. Enables Chrome WebView debugging (`chrome://inspect`). Do not ship with this enabled in production.