What's New / Privacy, Security & Identity

What's new in StoreKit

+18 New~4 Deprecated−1 RemovediOS · macOS · tvOS · watchOS · visionOS

StoreKit handles in-app purchases, subscriptions, and offer-code redemption on Apple platforms. It exposes types like Product, AppTransaction, and AppStore for querying products, validating transactions, and presenting purchase flows.

The 27 SDK adds 18 APIs, including the StoreType, AppTransactions, RedeemOption, and Partner structs. AppTransaction gains storeType and all, Product.ProductType adds subscriptionBundle and subscriptionSuite cases, Product.SubscriptionInfo gains bundledSubscriptions, and StoreKitError adds invalidPresentationContext. Four APIs are deprecated, including AppStore.presentOfferCodeRedeemSheet, AppTransaction.storeTypeStringRepresentation, and View.offerCodeRedemption. Product.PurchaseResult is removed.

New

18
extension

Product.SubscriptionInfo

NewiOStvOSwatchOS
extension Product.SubscriptionInfo
Declaration
extension Product.SubscriptionInfo {

    /// Properties and functionality specific to auto-renewable subscriptions included in a subscription bundle.
    public struct BundledSubscription : Equatable, Hashable, Sendable {

        /// The unique product identifier.
        public let id: Product.ID

        /// A localized display name of the product.
        public let displayName: String

        /// A localized description of the product.
        public let description: String

        /// The price of the product in local currency.
        public let price: Decimal

        /// A localized string representation of `price`.
        public let displayPrice: String

        /// Whether the product is available for family sharing.
        public let isFamilyShareable: Bool

        /// The group identifier for this subscription.
        public let subscriptionGroupID: String

        /// The level of this subscription relative to other subscriptions in the same group.
        public let subscriptionGroupLevel: Int

        /// A localized display name of the subscription's group.
        public let subscriptionGroupDisplayName: String

        /// Returns a Boolean value indicating whether two values are equal.
        ///
        /// Equality is the inverse of inequality. For any values `a` and `b`,
        /// `a == b` implies that `a != b` is `false`.
        ///
        /// - Parameters:
        ///   - lhs: A value to compare.
        ///   - rhs: Another value to compare.
        public static func == (a: Product.SubscriptionInfo.BundledSubscription, b: Product.SubscriptionInfo.BundledSubscription) -> Bool

        /// Hashes the essential components of this value by feeding them into the
        /// given hasher.
        ///
        /// Implement this method to conform to the `Hashable` protocol. The
        /// components used for hashing must be the same as the components compared
        /// in your type's `==` operator implementation. Call `hasher.combine(_:)`
        /// with each of these components.
        ///
        /// - Important: In your implementation of `hash(into:)`,
        ///   don't call `finalize()` on the `hasher` instance provided,
        ///   or replace it with a different instance.
        ///   Doing so may become a compile-time error in the future.
        ///
        /// - Parameter hasher: The hasher to use when combining the components
        ///   of this instance.
        public func hash(into hasher: inout Hasher)

        /// The hash value.
        ///
        /// Hash values are not guaranteed to be equal across different executions of
        /// your program. Do not save hash values to use during a future execution.
        ///
        /// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
        ///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
        ///   The compiler provides an implementation for `hashValue` for you.
        public var hashValue: Int { get }
    }
}
struct

RedeemOption

NewiOSmacOS
public struct RedeemOption : Equatable, Hashable, Sendable

An option that customizes the behavior of an offer code redemption.

Pass a set of these values to presentOfferCodeRedeemSheet(from:options:) to configure the offer code redemption.

Declaration
public struct RedeemOption : Equatable, Hashable, Sendable {

    /// Returns a Boolean value indicating whether two values are equal.
    ///
    /// Equality is the inverse of inequality. For any values `a` and `b`,
    /// `a == b` implies that `a != b` is `false`.
    ///
    /// - Parameters:
    ///   - lhs: A value to compare.
    ///   - rhs: Another value to compare.
    public static func == (a: RedeemOption, b: RedeemOption) -> Bool

    /// Hashes the essential components of this value by feeding them into the
    /// given hasher.
    ///
    /// Implement this method to conform to the `Hashable` protocol. The
    /// components used for hashing must be the same as the components compared
    /// in your type's `==` operator implementation. Call `hasher.combine(_:)`
    /// with each of these components.
    ///
    /// - Important: In your implementation of `hash(into:)`,
    ///   don't call `finalize()` on the `hasher` instance provided,
    ///   or replace it with a different instance.
    ///   Doing so may become a compile-time error in the future.
    ///
    /// - Parameter hasher: The hasher to use when combining the components
    ///   of this instance.
    public func hash(into hasher: inout Hasher)

    /// The hash value.
    ///
    /// Hash values are not guaranteed to be equal across different executions of
    /// your program. Do not save hash values to use during a future execution.
    ///
    /// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
    ///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
    ///   The compiler provides an implementation for `hashValue` for you.
    public var hashValue: Int { get }
}
func

AppStore.presentOfferCodeRedeemSheet

NewiOS
public static func presentOfferCodeRedeemSheet(from viewController: UIViewController, options: Set<RedeemOption> = []) async throws -> VerificationResult<Transaction>

Presents a sheet that enables users to redeem subscription offer codes that you configure in App Store Connect.

Parameters

viewController
The UIViewController that StoreKit uses to display the offer code redemption sheet.
options
A set of RedeemOption values to configure the offer code redemption.

ReturnsA VerificationResult containing the Transaction that the redemption produces. Throws: StoreKitError if the system cannot present the sheet or the redemption fails.

func

AppStore.presentOfferCodeRedeemSheet

NewmacOS
public static func presentOfferCodeRedeemSheet(from window: NSWindow, options: Set<RedeemOption> = []) async throws -> VerificationResult<Transaction>

Presents a sheet that enables users to redeem subscription offer codes that you configure in App Store Connect.

Parameters

window
The NSWindow that StoreKit uses to display the offer code redemption sheet.
options
A set of RedeemOption values to configure the offer code redemption.

ReturnsA VerificationResult containing the Transaction that the redemption produces. Throws: StoreKitError if the system cannot present the sheet or the redemption fails.

var

AppTransaction.all

NewiOSmacOStvOSwatchOS
public static var all: AppTransaction.AppTransactions { get }

Returns all the AppTransactions for this version of the app.

struct

AppTransaction.AppTransactions

NewiOSmacOStvOSwatchOS
public struct AppTransactions : AsyncSequence, Sendable
Declaration
public struct AppTransactions : AsyncSequence, Sendable {

    /// The type of element produced by this asynchronous sequence.
    public typealias Element = VerificationResult<AppTransaction>

    /// The type of asynchronous iterator that produces elements of this
    /// asynchronous sequence.
    public struct AsyncIterator : AsyncIteratorProtocol {

        /// Asynchronously advances to the next element and returns it, or ends the
        /// sequence if there is no next element.
        ///
        /// - Returns: The next element, if it exists, or `nil` to signal the end of
        ///   the sequence.
        public mutating func next() async -> VerificationResult<AppTransaction>?

        @available(macOS 27.0, iOS 27.0, tvOS 27.0, watchOS 27.0, *)
        public typealias Element = VerificationResult<AppTransaction>
    }

    /// Creates the asynchronous iterator that produces elements of this
    /// asynchronous sequence.
    ///
    /// - Returns: An instance of the `AsyncIterator` type used to produce
    /// elements of the asynchronous sequence.
    public func makeAsyncIterator() -> AppTransaction.AppTransactions.AsyncIterator
}
let

AppTransaction.storeType

NewiOSmacOStvOSwatchOS
public let storeType: AppTransaction.StoreType

The store where the original purchase of the app was made.

struct

AppTransaction.StoreType

NewiOSmacOStvOSwatchOS
public struct StoreType : RawRepresentable, Equatable, Hashable, Sendable
Declaration
public struct StoreType : RawRepresentable, Equatable, Hashable, Sendable {

    /// The corresponding value of the raw type.
    ///
    /// A new instance initialized with `rawValue` will be equivalent to this
    /// instance. For example:
    ///
    ///     enum PaperSize: String {
    ///         case A4, A5, Letter, Legal
    ///     }
    ///
    ///     let selectedSize = PaperSize.Letter
    ///     print(selectedSize.rawValue)
    ///     // Prints "Letter"
    ///
    ///     print(selectedSize == PaperSize(rawValue: selectedSize.rawValue)!)
    ///     // Prints "true"
    public let rawValue: String

    /// Creates a new instance with the specified raw value.
    ///
    /// If there is no value of the type that corresponds with the specified raw
    /// value, this initializer returns `nil`. For example:
    ///
    ///     enum PaperSize: String {
    ///         case A4, A5, Letter, Legal
    ///     }
    ///
    ///     print(PaperSize(rawValue: "Legal"))
    ///     // Prints "Optional(PaperSize.Legal)"
    ///
    ///     print(PaperSize(rawValue: "Tabloid"))
    ///     // Prints "nil"
    ///
    /// - Parameter rawValue: The raw value to use for the new instance.
    public init(rawValue: String)

    public static let consumer: AppTransaction.StoreType

    public static let education: AppTransaction.StoreType

    public static let enterprise: AppTransaction.StoreType

    /// The raw type that can be used to represent all values of the conforming
    /// type.
    ///
    /// Every distinct value of the conforming type has a corresponding unique
    /// value of the `RawValue` type, but there may be values of the `RawValue`
    /// type that don't have a corresponding value of the conforming type.
    @available(macOS 27.0, iOS 27.0, tvOS 27.0, watchOS 27.0, *)
    public typealias RawValue = String
}
typealias

AppTransaction.AppTransactions.AsyncIterator.Element

NewiOSmacOStvOSwatchOS
public typealias Element = VerificationResult<AppTransaction>
typealias

AppTransaction.StoreType.RawValue

NewiOSmacOStvOSwatchOS
public typealias RawValue = String

The raw type that can be used to represent all values of the conforming type.

Every distinct value of the conforming type has a corresponding unique value of the RawValue type, but there may be values of the RawValue type that don't have a corresponding value of the conforming type.

let

Product.ProductType.subscriptionBundle

NewiOSmacOStvOSwatchOS
public static let subscriptionBundle: Product.ProductType
let

Product.ProductType.subscriptionSuite

NewiOSmacOStvOSwatchOS
public static let subscriptionSuite: Product.ProductType
let

Product.SubscriptionInfo.bundledSubscriptions

NewiOSmacOStvOSwatchOS
public let bundledSubscriptions: [Product.SubscriptionInfo.BundledSubscription]

Properties and functionality specific to auto-renewable subscriptions included in a subscription bundle.

This list is only populated if type is .subscriptionBundle, and always empty for all other product types.

case

StoreKitError.invalidPresentationContext

NewiOSmacOStvOSwatchOS
case invalidPresentationContext

StoreKit UI cannot be presented from the current context.

struct

Transaction.AdvancedCommerceInfo.Partner

NewiOSmacOStvOSwatchOS
public struct Partner : Equatable, Hashable, Sendable
Declaration
public struct Partner : Equatable, Hashable, Sendable {

    /// The unique identifier you set for the app partner across your developer account.
    public let id: String

    /// The unique identifier you set for the app partner across your developer account.
    public let name: String?

    /// Returns a Boolean value indicating whether two values are equal.
    ///
    /// Equality is the inverse of inequality. For any values `a` and `b`,
    /// `a == b` implies that `a != b` is `false`.
    ///
    /// - Parameters:
    ///   - lhs: A value to compare.
    ///   - rhs: Another value to compare.
    public static func == (a: Transaction.AdvancedCommerceInfo.Partner, b: Transaction.AdvancedCommerceInfo.Partner) -> Bool

    /// Hashes the essential components of this value by feeding them into the
    /// given hasher.
    ///
    /// Implement this method to conform to the `Hashable` protocol. The
    /// components used for hashing must be the same as the components compared
    /// in your type's `==` operator implementation. Call `hasher.combine(_:)`
    /// with each of these components.
    ///
    /// - Important: In your implementation of `hash(into:)`,
    ///   don't call `finalize()` on the `hasher` instance provided,
    ///   or replace it with a different instance.
    ///   Doing so may become a compile-time error in the future.
    ///
    /// - Parameter hasher: The hasher to use when combining the components
    ///   of this instance.
    public func hash(into hasher: inout Hasher)

    /// The hash value.
    ///
    /// Hash values are not guaranteed to be equal across different executions of
    /// your program. Do not save hash values to use during a future execution.
    ///
    /// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
    ///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
    ///   The compiler provides an implementation for `hashValue` for you.
    public var hashValue: Int { get }
}
let

Transaction.AdvancedCommerceInfo.Item.Details.partners

NewiOSmacOStvOSwatchOS
public let partners: [Transaction.AdvancedCommerceInfo.Partner]

The partners associated with this item.

case

Transaction.RefundRequestError.ineligible

NewiOSmacOStvOSwatchOS
case ineligible
func

View.offerCodeRedemption

NewiOSmacOS
nonisolated public func offerCodeRedemption(options: Set<RedeemOption>, isPresented: Binding<Bool>, onCompletion: @escaping @MainActor (Result<VerificationResult<Transaction>, any Error>) -> Void) -> some View

Presents a sheet that enables customers to redeem offer codes that you configure in App Store Connect.

The offerCodeRedemption(options:isPresented:onCompletion:) method displays a system sheet where customers can enter and redeem offer codes. If you generate offer codes in App Store Connect, call this method to enable customers to redeem the offer. To display the sheet using UIKit, see presentOfferCodeRedeemSheet(from:options:).

Important: Set up offer codes in App Store Connect before calling this API. Customers can only redeem these offers in your app through the redemption sheet; don’t use a custom UI. For more information, see <doc://com.apple.documentation/documentation/storekit/appstore/supporting_subscription_offer_codes_in_your_app>.

The following code example shows a view that displays the offer code redemption sheet when the customer taps a button:

import SwiftUI
import StoreKit

struct ContentView: View {
    @State private var redeemSheetIsPresented = false

    var body: some View {
        Button("Present offer code redemption sheet.") {
            redeemSheetIsPresented = true
        }
        .offerCodeRedemption(
            options: [],
            isPresented: $redeemSheetIsPresented
        ) { result in
            // Handle result
        }
    }
}

When the customer successfully redeems an offer code, the system delivers the resulting transaction through onCompletion, as a VerificationResult that wraps the Transaction.

Parameters

options
A set of RedeemOption values that configure the code redemption.
isPresented
A binding to a Boolean value that determines whether the system displays the sheet. You set the Boolean value to true to cause the system to display the sheet. The system sets it to false when it dismisses the sheet.
onCompletion
A closure the system calls with the result of the redemption. On success, the closure receives a VerificationResult containing the Transaction that the redemption produces. On failure, it receives the error that caused the redemption to fail.

Deprecated

4
func

AppStore.presentOfferCodeRedeemSheet

DeprecatediOSvisionOS
public static func presentOfferCodeRedeemSheet(in scene: UIWindowScene) async throws

Displays a sheet in the window scene that enables users to redeem a subscription offer code that you configure in App Store Connect

Important: The resulting transaction from redeeming an offer code is emitted in Transaction.updates. Set up a transaction listener as soon as your app launches to receive new transactions while the app is running.

Note: On apps built with Mac Catalyst, this method will return an error on versions prior to macOS 15.0.

Parameters

scene
The UIWindowScene used to display the offer code redemption sheet.

ReturnsThrows: StoreKitError

func

AppStore.presentOfferCodeRedeemSheet

DeprecatedmacOS
public static func presentOfferCodeRedeemSheet(from controller: NSViewController) async throws

Presents a sheet that enables users to redeem subscription offer codes that you configure in App Store Connect.

Parameters

controller
The view controller that StoreKit uses to present the offer code redemption sheet.

ReturnsThrows: StoreKitError

var

AppTransaction.storeTypeStringRepresentation

DeprecatediOSmacOStvOSvisionOSwatchOS
public var storeTypeStringRepresentation: String { get }
DeprecatedUse the storeType property instead.

The string representation of the store where the original purchase of the app was made. @DeprecationSummary { Use the storeType property instead.}

func

View.offerCodeRedemption

DeprecatediOSmacOSvisionOS
nonisolated public func offerCodeRedemption(isPresented: Binding<Bool>, onCompletion: @escaping @MainActor (Result<Void, any Error>) -> Void = { _ in }) -> some View

Presents a sheet that enables customers to redeem offer codes that you configure in App Store Connect.

The offerCodeRedemption(isPresented:onCompletion:) method displays a system sheet where customers can enter and redeem offer codes. If you generate offer codes in App Store Connect, call this function to enable customers to redeem the offer. To display the sheet using UIKit, see presentOfferCodeRedeemSheet(in:).

Important: Set up offer codes in App Store Connect before calling this API. Customers can only redeem these offers in your app through the redemption sheet; don’t use a custom UI. For more information, see <doc://com.apple.documentation/documentation/storekit/appstore/supporting_subscription_offer_codes_in_your_app>.

The following code example shows a view that displays the offer code redemption sheet upon a button press:

import SwiftUI
import StoreKit

struct ContentView: View {
    @State private var redeemSheetIsPresented = false

    var body: some View {
        Button("Present offer code redemption sheet.") {
            redeemSheetIsPresented = true
        }
        .offerCodeRedemption(isPresented: $redeemSheetIsPresented) { result in
            // Handle result
        }
    }
}

When customers redeem an offer code, StoreKit emits the resulting transaction in <doc://com.apple.documentation/documentation/storekit/transaction/updates>. Set up a transaction listener as soon as your app launches to receive new transactions while the app is running.

Parameters

isPresented
A binding to a Boolean value that determines whether the system displays the sheet. You set the Boolean value to true to cause the system to display the sheet. The system sets it to false when it dismisses the sheet.
onCompletion
A closure that returns the result of the presentation. In Mac apps built with Mac Catalyst, the completion handler returns a failure with an error prior to macOS 15.

Removed

1
extension

Product.PurchaseResult

RemovediOSmacOS
extension Product.PurchaseResult : Sendable
RemovedAbsent from the 27 SDK interface. Declaration shown is from the 26 SDK.
Declaration
extension Product.PurchaseResult : Sendable {
}

No APIs match your filter.

← More in Privacy, Security & Identity