The project is at this Github Repository. The file with the code is at components/Soundboard.js
This code was working previously, but now it looks like the promise is running forever. It looks like neither the resolve function, nor the reject function are executing because if I uncomment all the commented lines below and call the function askForPurchase()
the only things printed to the console are
- an object that looks like
"_40": 0, "_55": {"_40": 0, "_55": null, "_65": 0, "_72": null}, "_65": 3, "_72": null}
for the lineconsole.log(RNIap.getPurchaseHistory())
- and then the word
end
.
The buyProduct()
function also is no longer initializing an IAP.
const buyProduct = function(){ RNIap.requestPurchase("1985162691", 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`) }}
EXTRA
This code was working a few months ago and I even pulled a commit(1b9cb81f229680e173ce910892dddedc632c1651, comment: "Made the seal pic more cartoony") from that time to test out. After pulling this commit, I deleted my node_modules and pods, and cleaned my build folder, but the askForPurchase()
and buyProduct()
functions no longer work in that commit either.
I am testing this on a real iPhone SE running ios 13.6.1
I created a sandbox tester if you need to test it out, but I don't think you'll need it
email: rniapsandbox@gmail.compw: Somepassword1