---
title: "What does StoreKitError.invalidPresentationContext mean?"
description: "StoreKitError.invalidPresentationContext means StoreKit cannot show its UI from the current context. Call StoreKit views and sheets from a visible scene on the main actor. Available from iOS 27."
url: https://revenuedot.app/docs/errors/storekit-error-invalid-presentation-context
---

# 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

1. Start the StoreKit call from the main actor and while the app has a foreground scene, for example from a button handler.
2. Pass the scene that is on screen when an API takes one (`beginRefundRequest(in:)` takes a `UIWindowScene`).
3. Do not start purchase or refund flows from a background task, an extension or a scene that is closing.
4. 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?](https://revenuedot.app/docs/errors/storekit-error-unsupported.md)
- [What does StoreKitError.systemError mean?](https://revenuedot.app/docs/errors/storekit-error-system-error.md)
- [What does storeProblemError (code 2) mean in the purchases SDK?](https://revenuedot.app/docs/errors/sdk-store-problem-error.md)

## Source

- [Apple: StoreKitError.invalidPresentationContext](https://developer.apple.com/documentation/storekit/storekiterror/invalidpresentationcontext)
- [Apple: StoreKitError](https://developer.apple.com/documentation/storekit/storekiterror)
- [RevenueDot purchases-ios: StoreKitError+Extensions.swift (how the SDK maps StoreKit 2 errors)](https://github.com/revenuedot/purchases-ios/blob/revenuedot/main-patches/Sources/Error%20Handling/StoreKitError%2BExtensions.swift)

Checked: 2026-10-03
