purchases-ios: Purchase sheet may fail to appear on iOS 18.2
UPDATE 2025/03/03: iOS 18.3 fixed this issue.
UPDATE 2025/01/22: It seems iOS 18.3 RC fixes this issue and will be generally available very soon.
There’s a bug introduced by Apple in iOS 18.2 which prevents the payment sheet from being displayed if the current scene’s key window root view controller is not part of the view hierarchy.
When the issue manifests, there is a log error message printed in the console: Could not get confirmation scene ID for
This can happen if it is currently presenting a modal view controller with:
modalPresentationStyle = .fullScreenon UIKitfullScreenCover(isPresented:onDismiss:content:)in SwiftUI
To workaround the issue:
- Use
modalPresentationStyle = .overFullScreenon UIKit - Use
sheet(isPresented:onDismiss:content:)on SwiftUI
If your app manifests the issue but these workarounds do not apply to your view structure, make sure your root view controller is part of the view hierarchy when initiating a purchase.
We’re working on a workaround so purchases continue to work for users of our SDK: https://github.com/RevenueCat/purchases-ios/pull/4610
Technical details
Apple added a new purchase method in iOS 18.2 which accepts a UIViewController, as well as a macOS 15.2 one that accepts an NSWindow.
https://developer.apple.com/documentation/storekit/product/purchase(confirmin:options:)-3bivf https://developer.apple.com/documentation/storekit/product/purchase(confirmin:options:)-8eai6
All the purchase methods were reimplemented internally, and the old purchase(confirmIn:scene) and purchase(options:) methods end up calling the new purchase(confirmIn:viewController) method.
To select which UIViewController to pass as parameter, the algorithm roughly translates to:
UIApplication.shared.connectedScenes.filter { $0.activationState == .foregroundActive }?.keyWindow?.rootViewController
However, when you present a view controller with modalPresentationStyle = .fullScreen over the rootViewController the documentation says: The views belonging to the presenting view controller are removed after the presentation completes.
This is equivalent to doing:
// self is a UIViewController
self.view.removeFromSuperview()
try await product.purchase(confirmIn: self, options: [])
Which sure enough produces the dreaded Could not get confirmation scene ID for message.
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 6
- Comments: 25 (8 by maintainers)
@FurkanHanciSecond sorry to hear you’re hitting this issue. I’m hoping the recommendations from the issue details can help you track down the root cause of the bug in your app and potentially fix the issue.
@astrokin I believe your apps are experiencing this exact issue, but it’s not relaxed to the country of origin. I was able to download your apps and reproduce the issue where the payment sheet does not pop up and I can see the message
Could not get confirmation scene ID forusing Console.app. I also recommend checking the instructions in the issue details which can help you track down the root cause of the bug in your app and potentially fix it.@euroboy If payment sheet does not open sometimes, it can be because of this issue. Do you see the
Could not get confirmation scene ID formessage in the Xcode logs when that happens? The reason for the missing free trial information could be you’re using an Apple Sandbox account that has already purchased before. If so I recommend creating a new Sandbox Account to test it.To all three, if you’re unable to track down the issue in your apps please write to me at mark (at) revenuecat.com and I will try to help you personally.
@Lakston @lukepighetti the short answer is “yes it could”
The bug is not specific to the RevenueCat SDK or the UI framework you’re using, but to StoreKit, Apple’s iOS framework for in-app purchases.
The best way to test if your app is affected is trying to make a purchase on an iOS 18.2 device or simulator. If the purchases sheet pops up that means your app is not affected.
@Toni77777 do you also see the
Could not get confirmation scene ID formessage? If not, you might be experiencing a different issue.@butterfly-valley glad to know it’s working for you now 😃
Same Here! i’m getting the issue, i think it is really certain cause my customers cannot purchase in my prod apps.
Ok just tried that branch and it seems to be working. I’ll try to rush my build through review and see if customers are still seeing the issue. Thanks!
Hi @inb4ohnoes,
Thanks for reporting this. Indeed it seems like StoreKit payments fail 100% of the time in App Extensions.
I’ve added a workaround specifically for App Extensions to the
purchase-18.2branch. Could you test it and let me know if it fixes the issue for you?https://github.com/RevenueCat/purchases-ios/pull/4610/commits/26c5a6a44c976431e7aedad98543577ffea13ce3