listener "purchaseUpdatedListener" is saved many times in my database LOOP?
See original GitHub issueVersion of react-native-iap ^5.1.1
Version of react-native 0.63.2
Platforms you faced the error (IOS or Android or both?) IOS,
Expected behavior
After viewing the list of products to the options that a person can subscribe.
When I click on subscribe. Show the apple-Store buy window. after accepting, it is saved in my backend only once. Later I will do other things like validate received etc.
thereafter. Redirect to another screen as the case may be.
Actual behavior
After subscribing to a product, the first time it is saved to my back-end, once it is successful
if I exit the application and enter again but now I subscribe to another product
is saved many times up to 10-20-30 times is too many times, that’s the first time.
If I wait like 30 minutes and do it again. (Save once) but if I do it it repeats and saves many times
When I do that after 10 minutes, I really don’t know the time, because it does strange things.
When I go to the products view, I still do not subscribe and it is automatically saved in my backend 10-20-30 times
“The funny thing is that the receipt I don’t know how it still exists”
The purchaseUpdatedListener listener seems to repeat many times
I don’t know if something is being saved in the phone’s memory, or something is not making NULL that listener
Tested environment (Emulator? Real Device?) Real Device Iphone 8
Steps to reproduce the behavior
Ignore the titles of the purchases, I fix it later
these are two products that are to subscribe.
when is the first time. Do this.
My code ` useEffect(() => { IAP.initConnection().then(()=>{
IAP.getProducts(productIds).then(res => {
setProducts(res)
});
purchaseUpdateSubscription = purchaseUpdatedListener(async(purchase :InAppPurchase | SubscriptionPurchase) => {
const receipt = purchase.transactionReceipt
if(receipt) {
try {
console.log('entra')
if(Platform.OS === 'ios') {
await finishTransactionIOS(purchase.transactionId)
}
await finishTransaction(purchase)
}catch(error){
//console.log(error)
}
}
},
);
})
return () => {
purchaseUpdateSubscription.remove()
purchaseUpdateSubscription = null
};
}, []);
`
-
When you make your first purchase. It is not saved many times (just once) sometimes up to 2 times.
-
When you close the app and do another test. Saved many times 20-30 times
-
When you just access the products view, it is saved in automatic (I do not understand this behavior, because I have not yet clicked buy)
-
How does it continue to enter the condition of the receipt, how does it continue to exist?
this is my log
ignore the time with my log, I still don’t configure my Backend
this happens many times. How do I fix this?
Issue Analytics
- State:
- Created 3 years ago
- Reactions:5
- Comments:11 (1 by maintainers)
This is likely a bug with sandbox. Nothing happens in prod. You can safely release your app @pct. The iOS App Reviewers never rejected mine even if the bug existed in sandbox mode.
This issue also happens on prod. This is a bloody bug. Hope it gets fixed ASAP.