Skip to content
Indiana
Dashboard
Docs
Browse docs / iOS / Swift integration

iOS / Swift integration

Install the native SDK, read customer data and verify Sandbox store delivery.

SDK 0.0.1Updated

1. Install the native SDK

Add the reviewed GrooveGrow Swift Package from packages/ios in Xcode and link the GrooveGrow library. The source package requires Swift 6 and supports iOS 15 and later.

These are repository source packages; public SPM or Maven distribution has not been certified. Verify identity and readHoldings before adding Funnel and store purchases.

2. Issue the current customer's session

  • Your backend verifies the app login, then identifies the customer and issues a short-lived customerToken using a Server Key bound to this App and Sandbox. Do not trust a customer identity supplied by the device.
  • Configure the SDK with the HTTPS API URL, App UUID and Sandbox scope. The server verifies the environment binding. Never ship Console sessions, Server Keys or Supabase secrets in the app.
  • The SDK keeps the token in memory. Refresh through your authenticated backend. Clear current customer data and authenticate again after 401 / 403.

Related:Identity and credential boundaries

3. Connect and read customer data

GrowSession.swift
import Foundationimport GrooveGrow func connectGrow(baseURL: URL, projectID: UUID,                 customerToken: String, runToken: String) async throws -> (GrooveGrowClient, GrowFunnelSession) {    let client = GrooveGrowClient(configuration: try GrowConfiguration(        baseURL: baseURL,        scope: GrowScope(projectId: projectID, environment: .sandbox)))    try await client.identify(customerToken: customerToken)    _ = try await client.readHoldings()    let flow = try await client.funnel(runToken: runToken)    return (client, flow)} // Present GrowFunnelViewController(session: flow) on your MainActor UI.// Set onAuthenticate to obtain the current user's token from your backend.// Recover: try await client.recoverNativeOrders(using: verifiedHostRelay)// Explicit store sync: recoverNativeOrders(using: verifiedHostRelay, synchronizeStore: true)// On sign-out: await client.reset(); dismiss the old Funnel view.

Connection checkpoint

Show connected only after readHoldings succeeds for the current customer. Preserve decimal credits. Cancel host tasks on account changes or navigation, reject late responses and clear the previous snapshot as a whole.

4. Bind and verify Sandbox store purchases

  • In Payment connections, configure and verify the Apple or Google connection for this App and Sandbox, then bind products. Store product identifiers, app identity and connection must agree.
  • Pass the current runToken to client.funnel and present GrowFunnelViewController. native_purchase queries the real StoreKit product and terms before purchase; use recoverNativeOrders on foreground and synchronizeStore: true for explicit restoration.
  • Closing a store sheet or receiving a client callback is not delivery proof. Wait for server verification and delivery. Retain the current orderId, receiptId and original command rather than starting another purchase. The authenticated host relay adds its Server Key and uses the current customerToken for double authentication; never ship the key to a device. The server owns Google acknowledge / consume.

5. Acceptance and recovery

Native acceptance criteria
ScenarioExpected result
First connectionHoldings match Console customer details; invalid, expired and cross-scope sessions are rejected.
Sign-out and account changeClear old data immediately; old requests cannot overwrite the new customer; authenticate again after restart.
Network loss and timeoutShow a retryable error without success; retry the original request after reconnection.
Purchase, restore and refundDeliver a real Sandbox transaction once; restoration does not duplicate grants; verified refunds and revocations reach entitlements and history.

Native acceptance criteria

  • First connection

    Expected result
    Holdings match Console customer details; invalid, expired and cross-scope sessions are rejected.
  • Sign-out and account change

    Expected result
    Clear old data immediately; old requests cannot overwrite the new customer; authenticate again after restart.
  • Network loss and timeout

    Expected result
    Show a retryable error without success; retry the original request after reconnection.
  • Purchase, restore and refund

    Expected result
    Deliver a real Sandbox transaction once; restoration does not duplicate grants; verified refunds and revocations reach entitlements and history.
Record the device or simulator, test App, store account, transaction and server receipts separately. HTTP fixtures, compilation, platform selection and this checklist do not certify the real store chain.