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.
This example uses the standard Onside login flow. If you enable external login, configure Apple Pay before purchases, use consumable products, and handle the additional pre-flight errors described in Making a Purchase.
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:
loadProductfetches the product andonsideProductsRequest(_:didReceive:)delivers it.buyadds the product to the payment queue. If the user is not logged in, OnsideKit presents the login screen automatically and resumes the purchase afterwards.Each state change is delivered to
onsidePaymentQueue(_:updatedTransactions:), where you unlock content and finish the transaction.
Next steps
Initializing the SDK — the
Info.plistURL scheme,callbackScheme, andhandle(url:)in detailAuthentication & User Account — how login works and how to check session state
Fetching Products — reading titles, prices, and subscription details
Making a Purchase — purchase and restore flows, errors, and the storefront safety gate
Local Testing with a .storekit File — try the whole flow without a backend
Last updated
Was this helpful?