For the complete documentation index, see llms.txt. This page is also available as Markdown.

Quick Start

A minimal, end-to-end OnsideKit integration you can copy-paste: initialize the SDK, fetch a product, buy it, and finish the transaction.

This is the shortest path from zero to a completed purchase with OnsideKit. Copy the two files below, replace the placeholders, and you have a working flow. Each step links to a deeper guide when you need more detail.

Before you start

1. Initialize the SDK and handle URLs

Do this once at launch, in your AppDelegate. Onside.initialize() must be called before any other OnsideKit API.

import UIKit
import OnsideKit

@main
final class AppDelegate: UIResponder, UIApplicationDelegate {

    // Keep a strong reference to your purchase manager for the app's lifetime.
    let store = PurchaseManager()

    func application(
        _ application: UIApplication,
        didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
    ) -> Bool {
        // 1. Initialize OnsideKit before calling any other OnsideKit API.
        Onside.initialize()

        // 2. Provide the callback URL scheme you declared in Info.plist.
        Onside.callbackScheme = "com.yourapp.onside"

        // 3. Register a transaction observer as early as possible. The payment
        //    queue stays idle until at least one observer is registered.
        Onside.defaultPaymentQueue().add(observer: store)

        return true
    }

    // 4. Forward incoming URLs so the app-to-app login flow can finish.
    func application(
        _ app: UIApplication,
        open url: URL,
        options: [UIApplication.OpenURLOptionsKey: Any] = [:]
    ) -> Bool {
        Onside.handle(url: url)
    }
}

2. Create a purchase manager

A single object fetches products, starts purchases, and processes transactions. The payment queue only makes progress while at least one observer is registered (that is why we add it at launch in step 1).

3. Run the flow

Kick everything off from your UI — for example, load a product when a screen appears:

The flow then runs on its own:

  1. loadProduct fetches the product and onsideProductsRequest(_:didReceive:) delivers it.

  2. buy adds the product to the payment queue. If the user is not logged in, OnsideKit presents the login screen automatically and resumes the purchase afterwards.

  3. Each state change is delivered to onsidePaymentQueue(_:updatedTransactions:), where you unlock content and finish the transaction.

OnsideKit delivers all delegate and observer callbacks on the main actor, and you must retain request objects and observers yourself. See Threading & Object Lifetime.

Next steps

Last updated

Was this helpful?