PeterStaev / nativescript-purchase

:moneybag: A NativeScript plugin for making in-app purchases!
Apache License 2.0
83 stars 28 forks source link

purchase.getProducts() - UNKNOWN_ERROR #113

Closed jgmedialtd closed 3 years ago

jgmedialtd commented 3 years ago

I've followed the installation and guides thoroughly - everything is setup correctly on the Apple side of things, so I think we can discount that.

However no matter what I use to init purchase, the getProducts() method always returns Error: UNKNOWN_ERROR when used in a try / catch block.

I've set things up so I can type in a product id, as I suspected that was the issue and init / getProducts repeatedly - this is after two days of trying to get things to work.

Here's my setup:

"@nativescript/core": "^8.0.6",
"@nativescript/theme": "^3.0.1",
"@proplugins/nativescript-purchase": "^6.0.0",
"nativescript-vue": "^2.9.0"
initPurchase() {
    console.log("initPurchase triggered with " + this.productID);
    purchase
        .init([this.productID])
        .then(() => {
            console.log("purchase.init complete");
            this.getProducts();
        })
        .catch((err) => console.error("Error with purchase.init", err));
}

getProducts() {
    purchase
        .getProducts()
        .then((products) => {
            console.log("purchase.getProducts complete");
            this.products = products;
            console.log(Object.keys(products));
        })
        .catch((err) =>
            console.error("Error with purchase.getProducts", err)
        );
}
PeterStaev commented 3 years ago

Hey @jgmediadesign , are you testing on a simulator or on a real device? Since iOS14 sadly you cannot test on simulator at all and you need to use a real device.

jgmedialtd commented 3 years ago

Hi @PeterStaev - thanks for getting back so quickly. So you can't even retrieve products on the simulator? I've tried on a real device and can confirm it works as expected. Thanks for your help and keep up the good work!

PeterStaev commented 3 years ago

Sadly yes. Apple broke simulator product retrieval in iOS14 😞 It was working fine before that.

jgmedialtd commented 3 years ago

Thanks so much for your help @PeterStaev