React-native-iap: purchaseUpdatedListener being called multiple, sometimes 20+ times

Created on 8 Sep 2020  ·  12Comments  ·  Source: dooboolab/react-native-iap

Version of react-native-iap

"react-native-iap": "^4.5.3"

Version of react-native

"react-native": "0.62.0"

Platforms you faced the error (IOS or Android or both?)

iOS (havent tested on android yet)

Expected behavior

purchaseUpdatedListener should only be as called as many times as the component has mounted

Actual behavior

purchaseUpdatedListener was called 20 times in a couple of seconds, every so often when I open the app it get's called multiple times

Tested environment (Emulator? Real Device?)

Real device, sandbox env

Steps to reproduce the behavior

Follow instructions as per main page

I currently have purchaseUpdatedListener being attached to a listener in componentDidMount(), sometimes when I open up my app it will fire multiple times. This is happening on txns that I have called finishTransaction on. Is anyone seeing something like this?

🕵️‍♂️ need more investigation 🙏 help wanted 🤖 android

Most helpful comment

Same here. At every auto-renew event, I receive the actual auto-renewable subscription and a few seconds later I receive a big chunk of 135 purchase objects from the purchaseUpdatedListener. I feel this is my entire purchase history. I tried to call both finishTransaction and finishTransactionIOS to consume the transactions but it doesn't change anything.

At the next auto-renew event, that big chunk of transactions is increasing (136, 137,...). The transactions are only my auto-renew subs. None of my consumable/non-consumable products appear on the list.

All 12 comments

Same for me, but I call purchase flow in action

const { productId } = args
purchaseUpdatedListener(async (purchase) => {
    if (!purchase.transactionReceipt) {
        Alert("Error")
    }
    ...
})
purchaseErrorListener(error => {
    ...
})
await requestPurchase(productId, false)

I have 4 test products and I receive purchaseUpdatedListener 4 times, but the purchase was requested only for one of them

Tried finish those transactions but still multiple calls

Is the item an auto-renew? I think what is happening is because it's in the sandbox the renew period is only 5 mins for my monthly subscription. So apple will send an event on each renew, so if the app was closed for 10 mins, that's 2 notifications I'll get when the app opens.

Can anyone confirm this is the expected behavior to get notifications on an auto-renew and not just on the purchase?

My purchase is one time consumable

Same here. At every auto-renew event, I receive the actual auto-renewable subscription and a few seconds later I receive a big chunk of 135 purchase objects from the purchaseUpdatedListener. I feel this is my entire purchase history. I tried to call both finishTransaction and finishTransactionIOS to consume the transactions but it doesn't change anything.

At the next auto-renew event, that big chunk of transactions is increasing (136, 137,...). The transactions are only my auto-renew subs. None of my consumable/non-consumable products appear on the list.

Same here, I confirm it calls the listener the same amount of times as the number of purchases in the purchase history.

I have some problem. It is happening only when subscription is enabled.

I had a similar experience with iOS 14.

My app sells an auto-renewal subscription.
I think this issue has occurred since I purchased the same subscription again.

The following link may be relevant to this issue.
https://developer.apple.com/forums/thread/659529

take a look this post
the problem is finishTransaction and finishTransactionIOS not work for iOS now, these alway return undefined , so that u can't finish transaction and they stuck in pending transaction. When u open your app, ALL pending transactions will be handled in purchaseUpdatedListener ... so that's why u got 20+ times.
:((( someone fix this plsssssss

take a look this post
the problem is finishTransaction and finishTransactionIOS not work for iOS now, these alway return undefined , so that u can't finish transaction and they stuck in pending transaction. When u open your app, ALL pending transactions will be handled in purchaseUpdatedListener ... so that's why u got 20+ times.
:((( someone fix this plsssssss

https://github.com/dooboolab/react-native-iap/issues/1160#issuecomment-716525603
I've posted a reply here and actually it is expected that finishTransaction does not resolve promise.
We need to verify that it actually finishes transaction by putting log in iOS side and check if it enters an if statement.

I am seeing the same as mentioned here: https://github.com/dooboolab/react-native-iap/issues/1172#issuecomment-721676878.

Was this page helpful?
0 / 5 - 0 ratings