feat: add Paywall onRestoreInitiated JS callback - #1923
Open
ninjz wants to merge 2 commits into
Open
Conversation
Bridge native restore-initiated gating to React Native, matching onPurchasePackageInitiated so hosts can identify the user before restore. Depends on a purchases-hybrid-common release that includes resumeRestoreInitiated. Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Reviewed by Cursor Bugbot for commit c7a2e3d. Configure here.
BasePaywallViewManager emits onRestoreInitiated for RCPaywallFooterView too. Full-screen JS always resumes; the footer view never listened, so a Restore tap hung. Wire the same handler (auto-true if omitted) and export the iOS footer view property.
Author
|
Fixed the Android footer hang: |
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Depends on: RevenueCat/purchases-hybrid-common#1843 (must be released and this SDK bumped to that hybrid-common version before this compiles on CI).
Native RevenueCat paywalls already gate restore before it starts (purchases-ios#6392, Android
PaywallListener.onRestoreInitiated). React Native never bridged it. Apps that must identify the user before StoreKit restore (logout leaves RC on the previous App User ID; restore would attach receipts to the wrong customer) have no hook. Purchase already hasonPurchasePackageInitiated+resume(requestId, shouldProceed). This adds the restore equivalent.JS API (same shape as purchase, minus package)
If
onRestoreInitiatedis omitted, JS auto-resume(true)(same asonPurchasePackageInitiated). If it is set, the host must callresume(true|false)or restore hangs.Wired on full-screen
RevenueCatUI.Paywalland the footer paywall (InternalPaywallFooterView/ iOS footer view property), matchingonPurchasePackageInitiated. AndroidBasePaywallViewManageremits the native event for both view types.Android footer: if the host never calls
resume, the SDK auto-resumes so restore cannot hang (same failure mode Bugbot flagged).Native
RCT_EXPORT_VIEW_PROPERTY(onRestoreInitiated)on full-screen and footer,PaywallViewWrapperimplementspaywallViewController:didInitiateRestoreWithRequestId:,RNPaywalls.resumeRestoreInitiatedOnRestoreInitiatedEvent,PaywallEventName.ON_RESTORE_INITIATED,RNPaywallsModule.resumeRestoreInitiated→PaywallListenerWrapper.resumeRestoreInitiatedNote for hybrid-common consumers
PaywallProxyis a Swiftpublicclass (objc_subclassing_restricted). Do not subclass it from ObjC/RN to add this hook — implementdidInitiateRestoreWithResume:onPaywallProxyitself (hybrid-common #1843). A local RN 10.7.1 patch can use an ObjC category as a stopgap until this ships.