Monday 31 August 2020

React Native: RNIap.getPurchaseHistory().then does not execute either of it's resolve or it's reject functions

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. 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 line console.log(RNIap.getPurchaseHistory())
  • and then the word end.

The buyProduct() function also is no longer functioning properly.

const buyProduct = function(){
    RNIap.requestPurchase("1985162691", false).then(purchase => {
        store.dispatch(setPurchases(purchase))
    }).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 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


If needed I can create a sandbox account for IAP, but it doesn't seem like I'll need to



from React Native: RNIap.getPurchaseHistory().then does not execute either of it's resolve or it's reject functions

No comments:

Post a Comment