react-native-purchases icon indicating copy to clipboard operation
react-native-purchases copied to clipboard

onPurchaseCompleted calls dismiss for Android (bad) but not for iOS (good)

Open ferrannp opened this issue 8 months ago • 4 comments

Describe the bug

  1. Environment
    1. Platform: React Native
    2. SDK version: 8.8.2
    3. 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.

ferrannp avatar Mar 26 '25 22:03 ferrannp

👀 We've just linked this issue to our internal tracker and notified the team. Thank you for reporting, we're checking this out!

RCGitBot avatar Mar 26 '25 22:03 RCGitBot

Hi @ferrannp, could you please share your full paywall code? Also are you using React Native's new architecture?

HaleyRevcat avatar Mar 31 '25 15:03 HaleyRevcat

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).

ferrannp avatar Mar 31 '25 15:03 ferrannp

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.

asnaseer avatar Apr 01 '25 16:04 asnaseer

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.

shedworth avatar Jul 29 '25 10:07 shedworth

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!

pm2877 avatar Jul 29 '25 23:07 pm2877

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: Image

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: Image

asnaseer avatar Aug 01 '25 11:08 asnaseer

I'm facing the same issue using

    "react-native-purchases-ui": "^9.0.0",

on Android.

do you have an idea @HaleyRevcat ?

budet-b avatar Aug 18 '25 16:08 budet-b

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

domantasdev avatar Aug 22 '25 09:08 domantasdev

Hi, Closing this ticket since the fix was released in this version.

nyeu avatar Oct 03 '25 15:10 nyeu