Home / IOS Development / ios – React Native: RNIap.getPurchaseHistory (). then runs indefinitely

ios – React Native: RNIap.getPurchaseHistory (). then runs indefinitely

The project is on this Github Repository. The file with the code is on components/Soundboard.js

This code used to work, but now it looks like the promise runs forever. It looks like neither the solution function nor the rejection function is running, because if I comment on all the commented lines below and call the function askForPurchase() the only thing printed on the console is

  • an object that looks like "_40": 0, "_55": {"_40": 0, "_55": null, "_65": 0, "_72": null}, "_65": 3, "_72": null} for the line console.log(RNIap.getPurchaseHistory())
  • and then the word end.

The buyProduct() the function also no longer initializes an IAP.

const buyProduct = function(){
985162691", false).then(purchase => { store.dispatch(setPurchases(purchase)) await RNIap.finishTransaction(purchase, false) //developerPayloadAndroid?: string Should I use this argument? I don't get how to use it }).catch((error) => { console.log(error.message); }) } const askForPurchase = function(){ if (!store.getState().purchase){ //console.log(RNIap.getPurchaseHistory()) RNIap.getPurchaseHistory().then(purchase => { //console.log(`test1`) store.dispatch(setPurchases(purchase)) if (purchase.length == 0){ //console.log(`test if`) buyProduct() }else{ //console.log(`test else`) RNIap.getAvailablePurchases() } }, reason => { console.log(reason) }) //console.log(`end`) } }


This code worked a few months ago, and I even made a commitment (1b9cb81f229680e173ce910892dddedc632c1651, comment: “Made the seal pic more cartoony”) from that time to test out. After making this commitment, I deleted node_modules and pods, and cleared my build folder, but askForPurchase() and buyProduct() features no longer work in that commitment either.

I’m testing this on a real iPhone SE running iOS 13.6.1

I created a sandbox tester if you need to test it, but I do not think you need it

email: rniapsandbox@gmail.com
pw: Somepassword1

Source link