1.sheet(isPresented: $paywall.displayPaywall) { PaywallView( offering: paywall.selectedOffering ?? Offering(identifier: "default", serverDescription: "default", availablePackages: []), displayCloseButton: true) .onPurchaseCompleted({ customerInfo in analyseFood() }) .onRestoreCompleted({ customerInfo in analyseFood() }) .ignoresSafeArea() }
iOS 16.7.10
RevenueCat 5.16.0
The iOS version is a bit old but I use a separate phone with a sandbox account for testing purchases though.
These callbacks are never called onPurchaseCompleted and onRestoreCompleted, also after test/sandbox purchase the Paywall doesn’t dismiss itself and stays on the screen. I have another screen written with UIKit and everything is OK with the Paywall UI invocation but SwiftUI version has weird problems.
Also its strange that I cannot pass offering as an optional value into Paywall.init as your SDK returns offerings as optional values.
------------------------------------------------------------------------------------------------
Am I doing in the sample something wrong, could you direct me please?
Hi @HenadziR - have you tried the presentPaywall or presentPaywallIfNeeded methods? These ways of triggering the paywall should automatically close the paywall, while the manual view needs to be closed when the callbacks are executed (I understand you’ve been having issues with the callbacks). Regarding the callbacks, is this only happening in your testing, or also in production?
Also, is this for Paywalls V1 or V2?
Frankly speaking I don’t understand these methods presentPaywall or presentPaywallIfNeeded. They are not convenient for me. This is for v2 the latest beta RevenueCat 5.16.0
@jeffrey_bunn I just want to show at the end of onboarding my paywall fullscreen but seems like this is not a use case with Revenue Cat, it is so basic I am surprised that it doesn’t work. Also delegates worked before the update, seems like a regression bug
Ok I found a way how to catch a completion by listening to .onRequestedDismissal callback and checking is any entitlements where activated or not. This should be stated somewhere in your documentation as I spent a decent amount of time on looking up in your codebase a correct callback to use.
Literally spent some 30-45 minutes browsing documentation around “Manual” implementation, it’s more useful to call ourselves PaywallView(), than using the “presentPaywallIfNeeded”.
Same outcome as @HenadziR callbacks onPurchaseCompleted and onRestoreCompleted are never called, and I’m not risking to upload this to PROD, going with the same solution as @HenadziR with the onRequestedDismissal.
Please, let us know when the proper callbacks are working, so we can implement them properly. Thanks!
FYI, using V2.
damn this seems so basic yet it took me a whole night to deal with.
var body: some View {
// This view immediately triggers RevenueCat's paywall presentation.
PaywallView(displayCloseButton: false, performPurchase: nil, performRestore: nil)
.onPurchaseCompleted { res in
print("YAY! THANK YOU")
print("res = \(res)")
onPurchaseCompleted()
}
.onPurchaseFailure { error in
print("purchase error \(error)")
}
.onRequestedDismissal {
}
}
the `onPurchaseCompleted` and `onPurchaseFailure` are never called but `onRequestedDismissal` is. Can someone please fix this already
Hi all, sorry about this. We recently merged a PR that fixes this, and it will go out in SDK releases this week.
I tried to use a fixed version(RevenueCat v5.17.0) with iOS18.3.1 / Xcode 16.2.
I confirmed that `onPurchaseStarted` and `onPurchaseCompleted` are called properly when purchase button is tapped. And PaywallView is dismissed after processing purchase.
However, when “restore purchase” button is tapped, `onRestoreStarted` is called, but `onRestoreCompleted` is not called. PaywallView is not dismissed.
What is a recommended way to handle restoring purchases?
1.sheet(isPresented: $showPaywall){ PaywallView() .onPurchaseStarted{ _ in print("onPurhaseStarted: ") } .onPurchaseCompleted{ _ in print("onPurchaseCompleted: ") } .onRestoreStarted { print("onRestoreStarted: ") } .onRestoreCompleted{ _ in print("onRestoreCompleted: ") }}
jeffrey_bunn wrote:
Hi all, sorry about this. We recently merged a PR that fixes this, and it will go out in SDK releases this week.
It’s almost working :s, they work sometimes and other don’t :S
Restored completed or fail never gets triggered.
s0flos wrote:
However, when “restore purchase” button is tapped, `onRestoreStarted` is called, but `onRestoreCompleted` is not called.
I’m experiencing the same issue, and I’m using version 5.18.0 of the SDK!
Bumping this. We found that when restoring purchases using the `PaywallViewController` and user has no active entitlements, there is no callback to the Paywall delegate. We'd expect the method `func paywallViewController(_ controller: didFinishRestoringWith customerInfo:)` would be called. Note only the `paywallViewControllerDidStartRestore(_ controller:)` method is called. Here are the logs:
RC [DEBUG]: Restoring purchases
RC [DEBUG]: Will execute restore purchases logic provided by RevenueCat.
Paywall :: did start restore <--- Initial delegate callback here
RC [DEBUG]: ℹ️ Found 0 unsynced attributes for App User ID: …
RC [DEBUG]: ℹ️ Skipping products request for these products because they were already cached: ["default_weekly"]
RC [DEBUG]: ℹ️ PostReceiptDataOperation: Started
RC [DEBUG]: ℹ️ PostReceiptDataOperation: Posting JWS token (source: 'restore'):
RC [DEBUG]: ℹ️ There are no requests currently running, starting request POST /v1/receipts
RC [DEBUG]: ℹ️ API request started: POST '/v1/receipts'
RC [DEBUG]: ℹ️ API request completed: POST '/v1/receipts' (200)
RC [DEBUG]: ℹ️ PostReceiptDataOperation: Finished
RC [DEBUG]: ℹ️ Serial request done: POST /v1/receipts, 0 requests left in the queue
RC [DEBUG]: Restored purchases successfully with no subscriptions
Using iOS SDK v5.18.0.
Is this intended behavior? Ideally we'd like to present a dialog informing the user about what happened (i.e. they have no active purchases etc).
@mar.pies is correct regarding this behavior:
We found that when restoring purchases using the `PaywallViewController` and user has no active entitlements, there is no callback to the Paywall delegate.
onRestoreCompleted on iOS will not fire if a restore is attempted but the user doesn’t have any active subscriptions. Notably, this is only on iOS. On Android, the method will fire if the user doesn’t have any active subscriptions. More information re: Android is available here.
@jeffrey_bunn does this mean it is intended behavior and that it will not be updated on iOS? I just noticed it was brought up earlier on Github without proper response.
@mar.pies That’s correct. That said, our team is working on unifying restore behavior / update these APIs, so please keep an eye out in the near future for updates.
Also looks like this was reported 8 months ago but never followed up on-
Restore completion handler seems like pretty important functionality?