onPurchaseCompleted calls dismiss for Android (bad) but not for iOS (good)
- [x] I have updated Purchases SDK to the latest version
- [x] I have read the Contribution Guidelines
- [x] I have searched the Community
- [x] I have read docs.revenuecat.com
- [x] I have searched for existing Github issues
Describe the bug
- Environment
- Platform: React Native
- SDK version: 8.8.2
- React Native version: 0.73.x
Basically, if you have:
<RevenueCatUI.Paywall
options={options}
onPurchaseStarted={onPurchaseStarted}
onPurchaseCancelled={onPurchaseCancelled}
onPurchaseCompleted={onPurchaseCompleted}
onPurchaseError={onError}
onRestoreCompleted={onRestoreComplete}
onRestoreError={onError}
onDismiss={onClose}
/>
The onDismiss will get called when a purchase is completed on Android but not on iOS. I believe iOS is correct here, the user should be in charge to do whatever on success.
Also for example, onRestoreCompleted does not trigger any dismiss so... The dismiss of onPurchaseCompleted only on Android, it seems like a bug to me.
👀 We've just linked this issue to our internal tracker and notified the team. Thank you for reporting, we're checking this out!
Hi @ferrannp, could you please share your full paywall code? Also are you using React Native's new architecture?
Still old architecture @HaleyRevcat. The code is just the one I posted. When you purchase it on Android, whatever function you pass in onDismiss gets called (on iOS it doesn't get called).
FYI: I am seeing the onDismiss callback being called on iOS. I am using version 8.9.1 of this library and have an Expo 51 React Native app which uses react version 0.74.5.
In our case, our onDismiss handler performed a navigation.goBack() where as the onPurchaseCompleted handler performed a navigation.navigate("some-other-screen");. What we saw was that right after a successful purchase, the app attempted to navigate to some-other-screen but then immediately went back to the paywall screen.
We ended up adding a state variable using React.useState to record whether or not we had made a successful purchase, and, if we had, then the onDismiss handler did nothing.
This seemed to resurface again in 8.11.9 (haven't tried latest version as it includes various breaking changes). We stopped receiving our "purchase completed" analytics events for Android users and found RevenueCatUI.Paywall's onPurchaseCompleted callback was fired after onDismiss. Since onDismiss contained a call to navigate away from the paywall screen, onPurchaseCompleted was never called, the result of which being multiple Google ad campaigns adversely affected.
This seemed to resurface again in 8.11.9 (haven't tried latest version as it includes various breaking changes). We stopped receiving our "purchase completed" analytics events for Android users and found RevenueCatUI.Paywall's onPurchaseCompleted callback was fired after onDismiss. Since onDismiss contained a call to navigate away from the paywall screen, onPurchaseCompleted was never called, the result of which being multiple Google ad campaigns adversely affected.
I think I may be facing this issue on Android. Using version 9.1.0. onDismiss gets called but onPurchaseCompleteddoesn't get called most of the times. When debugging, I see that on some rare occassions, it does get called along withonDismiss`. This is a huge problem!
Ok, so it looks like RC have comments in their example code for their paywall that indicates that the onDismiss callback is called when the user touches the close button or when a purchase is completed (see here). But this is not documented in their SDK or anywhere else:
It would be great if this was clearly documented in the SDK (e.g. via JS Docs) and on the list of callbacks further down on that page that currently just lists them without any explanations:
I'm facing the same issue using
"react-native-purchases-ui": "^9.0.0",
on Android.
do you have an idea @HaleyRevcat ?
We're also facing the same problem on Android - onDismiss gets called, but not onPurchaseCompleted. We'd like to use the purchase result data from purchase completion to send it to our backend, but we can't do that right now because of this issue.
We're using version 9.2.2
Hi, Closing this ticket since the fix was released in this version.