What does StoreKitError.invalidPresentationContext mean?
StoreKitError.invalidPresentationContext means StoreKit tried to show its own screen and could not, because the context it was given cannot present one.
Quick facts#
| Error | StoreKitError.invalidPresentationContext |
| Where | StoreKit 2, Swift (StoreKitError) |
| Available since | iOS 27.0, iPadOS 27.0, macOS 27.0, tvOS 27.0, watchOS 27.0, visionOS 27.0 |
| What the vendor says | StoreKit UI cannot be presented from the current context. |
Cause#
- Apple's case page gives only that one line. The case is listed under the enumeration cases of
StoreKitError, separate from the other error codes. - StoreKit shows system UI for purchase confirmation, refund requests and offer redemption. Each needs a window or scene to present from.
- The availability line in the StoreKit interface of the Xcode 27 SDK marks the case as new in version 27, so earlier systems never throw it.
Fix#
- Start the StoreKit call from the main actor and while the app has a foreground scene, for example from a button handler.
- Pass the scene that is on screen when an API takes one (
beginRefundRequest(in:)takes aUIWindowScene). - Do not start purchase or refund flows from a background task, an extension or a scene that is closing.
- Retry after the scene is visible again, and show a short message if it still fails.
Example#
Swift
import StoreKit
// invalidPresentationContext is new in version 27 systems, so check availability before you name it.
func describe(_ error: Error) -> String {
if #available(iOS 27.0, macOS 27.0, tvOS 27.0, watchOS 27.0, visionOS 27.0, *),
case StoreKitError.invalidPresentationContext = error {
return "StoreKit could not show its screen from here; try again from a visible scene"
}
return "Store error: \(error)"
}Compile-checked: npm run check:snippets type-checks this snippet with swiftc against the Apple SDK (macOS target, checked 2026-10-03).
How the RevenueDot SDK reports it#
The RevenueDot purchases-ios fork maps StoreKitError.invalidPresentationContext to ErrorCode.storeProblemError (code 2). The branch is compiled only with a Swift 6.4 compiler (Xcode 27).
Related#
- What does StoreKitError.unsupported mean?
- What does StoreKitError.systemError mean?
- What does storeProblemError (code 2) mean in the purchases SDK?
Source#
- Apple: StoreKitError.invalidPresentationContext
- Apple: StoreKitError
- RevenueDot purchases-ios: StoreKitError+Extensions.swift (how the SDK maps StoreKit 2 errors)
Checked: 2026-10-03