Skip to main content
Question

Restore completion handlers not firing in .presentPaywallIfNeeded

  • 12 June 2024
  • 7 replies
  • 105 views

Swiftui / Xcode 15.4 / iOS 17.5.1


When using the .presentPaywallIfNeeded modifier, I and not seeing any of the restore completion handlers called when that function is tapped. This includes restoreStarted, restoreCompleted or restoreFailed. The other completion handlers to include those around purchases and the onDismiss do fire correctly.

In my case, I don’t have a subscription to restore. When restore is invoked “DEBUG: Restored purchases successfully with no subscriptions” is returned to the console. However, there is no alert shown to the user. Whether it should be from RevCat or not is another question. However, looking to use the completion handlers to provide our own alert is not possible due to the completion handlers not functioning around restore.

The modifier is below., 

 

                .presentPaywallIfNeeded(
requiredEntitlementIdentifier: K.entitlementID,
offering: nil,
fonts: DefaultPaywallFontProvider(),
presentationMode: .sheet,
purchaseStarted: { package in
print("Purchase started")
},
purchaseCompleted: { info in
print("Purchase completed")
},
purchaseCancelled: {
print("Purchase cancelled")
},
restoreStarted: {
print("Restore started")
},
restoreCompleted: { info in
print("Restore completed")
},
purchaseFailure: { error in
print("Purchase failure")
},
restoreFailure: { error in
print("Restore failure")
},
onDismiss: {
shouldShowPaywall = false
})

 

 

This post has been closed for comments

7 replies

Userlevel 2
Badge +5

Hi @Scott,

Does the completion handler get fired when you have a subscription to restore?

Best,

Badge +3

Hi @joan-cardona - No, the handler does not get fired even when there is a subscription to restore. I see the “Debug” message in the console that says: “DEBUG: Restored purchases successfully with no subscriptions”. None of the handlers shown in my first post above are ever triggered with the restore operation. 

Thanks.

Userlevel 2
Badge +5

Hi @Scott,

Thanks for your message. I am trying to fully understand the issue to be able to reproduce it.

When you say that you saw: “DEBUG: Restored purchases successfully with no subscriptions” did you have any active subscription to restore and the system didn’t recognize it?

Or you didn’t have an active subscription at all?

Can you try subscribing to one, deleting the app, installing it again and do a restore and see what the console logs say?

 

Thank you,

 

Badge +3

Hi @joan-cardona  - That is exactly what I did. I purchased a sub, deleted the app, and then reinstalled. I then executed the restore operation which gave the above. In no case did any restore delegate fire. The delegates (not restore) did fire during initial purchase. 

Thanks. 

Badge +2

Hi @joan-cardona and @Scott . 

I am experiencing this problem as well. Didn't happen to me using older versions, and after deeply looking into it, this seems to be caused by this change , introduced in SDK 4.34.0. After this change, the

.onRestoreCompleted

 callback should be triggered after a dialog which shows something like 'Purchases restored' is dismissed, but this dialog is not appearing, so the callback is never triggered. I see in the console the message "DEBUG: Restored purchases successfully with no subscriptions" or "DEBUG: Restored purchases successfully with unlocked subscriptions".

 

In any of those cases, the restore is performed well under the hood, so if I close the app and reopen it, the entitlements were restored, but the callbacks for restoring purchases in the paywall are not called at all.

 

I am reproducing this bug in 2 of my apps, one of them in production. It is working fine using an SDK lower than 4.34.0

 

Thank you for any help! 😻

Badge +3

@kildos  - Thanks very much for jumping in here and providing this additional context. Hopefully, @joan-cardona or someone at RevCat will respond shortly. 

Userlevel 2
Badge +5

Hi @Scott  and @kildos,

Thank you so much for the context and for the details, this is very helpful.

I’m starting an investigation about it and I’ll let you know when I have more information.

 

Best,