question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

listener "purchaseUpdatedListener" is saved many times in my database LOOP?

See original GitHub issue

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

image

when is the first time. Do this.

image

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

image

ignore the time with my log, I still don’t configure my Backend

this happens many times. How do I fix this?

image

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:5
  • Comments:11 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
Yann-prakcommented, Jun 5, 2021

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.

1reaction
egulhancommented, Dec 29, 2021

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

listener "purchaseUpdatedListener" is saved many times in my ...
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...
Read more >
react-native-iap - Bountysource
Platforms you faced the error (IOS or Android or both?) IOS ... listener "purchaseUpdatedListener" is saved many times in my database LOOP? $...
Read more >
Async methods inside setPurchaseListener method calls ...
After spending a lot of time on debugging, I noticed that the purchase handler is being called only once; But on android it...
Read more >
How to use the react-native-iap.purchaseUpdatedListener ...
To help you get started, we've selected a few react-native-iap.purchaseUpdatedListener examples, based on popular ways it is used in public projects.
Read more >
WC()->shipping->get_packages() returns em...anycodings
WC()->shipping->get_packages() returns empty array I am trying to loop through my ... ... Sort Data and Time String in Javascript.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found