Tutorial: your first app
Configure the SDK and check access
Configure the SDK once, as the app launches, with the app's SDK key. After that, one synchronous call tells you whether to unlock a feature, and a stream tells you when that changes.
#Get the SDK key
Open the app's SDK & settings tab and copy the SDK key (it starts with pk_). It's safe to ship in your app: it only identifies the app, and it can't grant access or read anyone's data. One key works for Production, Sandbox, TestFlight and Xcode.

#Configure at launch
Call Horse.configure once, on the main thread, before anything else uses Horse.shared. In a SwiftUI app that's your App's init:
import SwiftUI
import HorseKit
@main
struct MyApp: App {
init() {
Horse.configure(apiKey: "pk_…",
baseURL: URL(string: "https://tally-api-755619271848.us-central1.run.app")!)
}
var body: some Scene {
WindowGroup { ContentView() }
}
}In a UIKit app, use application(_:didFinishLaunchingWithOptions:). The SDK & settings tab shows this snippet with your key already in it.
While you integrate, turn on debug logging:
Horse.configure(with: .init(apiKey: "pk_…",
baseURL: URL(string: "https://tally-api-755619271848.us-central1.run.app")!,
logLevel: .debug))Logs go to the unified log with the subsystem com.horse.sdk, so you can filter for them in Xcode's console or Console.app. Every option is listed in the SDK reference.
#Check access
Ask about the entitlement, never the product:
if Horse.shared.isEntitled("pro") {
showProFeatures()
}isEntitled is synchronous and safe from any thread. It reads the cached state on the device, so it's right even offline, and it also takes into account access the dashboard has blocked and an expiry that passed while the app was open.
#Follow changes
Access changes when someone buys, restores, gets a refund, or their subscription renews or ends. Follow the stream and your UI updates by itself:
struct ContentView: View {
@State private var isPro = Horse.shared.isEntitled("pro")
var body: some View {
HomeView(isPro: isPro)
.task {
for await info in Horse.shared.customerInfoStream { // now, then every change
isPro = info.isEntitled("pro")
}
}
}
}Horse is also an ObservableObject with @Published customerInfo, and it posts Horse.customerInfoDidChangeNotification, so whichever pattern your app already uses works.
#What the SDK does by itself
- Fetches the customer's access at launch and whenever the app comes back to the foreground (at most once a minute), and remote config every five minutes.
- Listens to StoreKit's
Transaction.updatesfor renewals, Ask to Buy approvals, purchases made outside the app and refunds, and sends them to Horse. - Works offline. A purchase unlocks at once and reaches Horse when the network is back, and access is read from the cache, then from StoreKit.
#Signed-in users
Without accounts, each install is an anonymous customer, and that's fine. If your app has its own sign-in, pass your user id so purchases follow the person across devices:
try await Horse.shared.logIn(user.id) // merges the anonymous customer into this one
try await Horse.shared.logOut() // back to a fresh anonymous idCustomers and accounts has more.