Modern Swift APIs for in-app purchases, subscriptions, and App Store integration. StoreKit 2 provides a declarative SwiftUI experience for managing transactions and subscriptions.
of iOS users worldwide can use StoreKit (iOS 15+ required)
| iOS Version | Market Share | Status |
|---|---|---|
| iOS 18.7 | 30.3% | Supported |
| iOS 18.6 | 29.8% | Supported |
| iOS 26.1 | 10.7% | Supported |
| iOS 18.5 | 6.0% | Supported |
| iOS 16.7 | 2.3% | Supported |
| iOS 26.2 | 2.0% | Supported |
| iOS 18.3 | 1.8% | Supported |
| iOS 15.8 | 1.8% | Supported |
| iOS 17.6 | 1.7% | Supported |
| iOS 26.0 | 1.3% | Supported |
Modern async/await Swift API
SwiftUI subscription views
Transaction history and receipts
Subscription status monitoring
Promotional offers and pricing
Server-to-server notifications
Load products from the App Store using StoreKit 2
import StoreKit
func loadProducts() async throws -> [Product] {
let productIDs = [
"com.example.subscription.monthly",
"com.example.consumable.coins"
]
let products = try await Product.products(for: productIDs)
return products
}Handle in-app purchase transactions
import StoreKit
func purchase(_ product: Product) async throws -> Transaction? {
let result = try await product.purchase()
switch result {
case .success(let verification):
let transaction = try checkVerified(verification)
await transaction.finish()
return transaction
case .userCancelled, .pending:
return nil
@unknown default:
return nil
}
}
func checkVerified<T>(_ result: VerificationResult<T>) throws -> T {
switch result {
case .unverified:
throw StoreError.failedVerification
case .verified(let safe):
return safe
}
}Listen for transaction updates
import StoreKit
func observeTransactionUpdates() -> Task<Void, Never> {
Task {
for await result in Transaction.updates {
do {
let transaction = try checkVerified(result)
// Deliver content to the user
await updatePurchasedProducts()
// Finish the transaction
await transaction.finish()
} catch {
print("Transaction verification failed")
}
}
}
}Modern Swift APIs for in-app purchases, subscriptions, and App Store integration. StoreKit 2 provides a declarative SwiftUI experience for managing transactions and subscriptions.
StoreKit is available on iOS 15 and later. Currently, 96.8% of iOS users worldwide can use this framework.
Related frameworks include Swiftui. Each has different capabilities and iOS version requirements.