dooboolab-community / react-native-iap

In App Purchase module for React Native!

Home Page:https://react-native-iap.dooboolab.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

purchaseUpdateListener is getting called multiple times in IOS

anuragdwivedi29 opened this issue · comments

Version of react-native-iap

4.0.4

Version of react-native

0.60.5

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

IOS

Expected behavior

should be called when requestSubscription(subscriptionID) is called

Actual behavior

is getting called when the app loads for the very first time.Also when a subscription is bought it is getting called multiple times

Tested environment (Emulator? Real Device?)

Real Device (sandbox environment)

Steps to reproduce the behavior

are there any pointers for the above mentioned issue?

maybe clearTransactionIOS() would help you , but i'm not sure :p
reference

ok i will try that but i am testing the in app purchase in sandbox environment .So when i am launching the app and before making any purchase it is calling the clearTransactionIOS() and is making the purchase which should not be the behaviour. Ideally only when the user makes the purchase the it should ask for the payment and make the purchase.So therefore i am not able to understand as to what i am doing wrong here.
Any pointers would be highly appreciated.Thanks

@anuragdwivedi29 if you did not finish transaction on app relaunch update listener will try automatically execute code inside.

Also do not forgot this.yourListener.remove() on unmount...

Maybe something of this you need. gl

commented

+1

This is happeening to me too. The difference is that I'm using the 3.2.3 version of RNIap.
I'm also removing the listener when unmounting, but the purchaseUpdateListener is getting called multiple times with differents transaction ids. Just happens in iOS.

Any ideas?

@nicolaswilliman @anuragdwivedi29 @mingxin-yang @franj0
I found the reason, refer this link(https://help.apple.com/app-store-connect/#/dev7e89e149d)

one auto-renewable subscription makes 6 renew transactions on Sandbox Environment
If you turn the app back on 20 minutes after subscribe a 1week
6 renew transactions that occurred every 3 minutes will enter the purchaseUpdatedListener at once

(on Production Environment, if a user that subscribes month plan re-payment after a month, the renew transaction will enter the purchaseUpdatedListener.)

@bang9 Do you have a solution for this? I understand that the purchaseUpdatedListener is being called multiple times

@bang9 Do you have a solution for this? I understand that the purchaseUpdatedListener is being called multiple times

If you don't want to getting six times of renew transactions after purchased auto-renewable subscription

1. purchase auto-renewable subscription
2. logout previous sandbox account
3. create a new sandbox account
4. login with new sandbox account

I don't think it is efficiently :P
six times of renew transaction is needed for testing renew properly

this is not above case

Perhaps a way to handle resubscribe events would be to reference originalTransactionDateIOS which is present in the given ProductPurchase? Is this field undefined on the initial purchase of a subscription?

commented

maybe clearTransactionIOS() would help you , but i'm not sure :p
reference

clearTransactionIOS method is deprecated.

If believe it might be worth checking to see if a 'purchase button' has been pressed, and then processing with your normal purchase flow. Otherwise you will have to do some extra logic to handle these resubscribe events.

I would suggest not deprecating clearTransactionIOS.

I have experience of implementing iOS IAP subscription that, unexpected numbers of transactions coming. I understand there are condensed intervals for sandbox testing environment, just as @bang9 mentioned above, but it was not the case.

It turned out that I implemented a mechanism similar to clearTransactionIOS to ignore any retrying transactions on app launch. So the user would need to manually restore purchase if any error happened, but it's a more clear and expected behavior.

commented

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as "For Discussion" or "Good first issue" and I will leave it open. Thank you for your contributions.

commented

Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please feel free to create a new issue with up-to-date information.