PeterStaev / nativescript-purchase

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

Cannot load the existing products #81

Closed ebalestrini closed 5 years ago

ebalestrini commented 5 years ago

Hi i have in my main.ts

import * as purchase from "nativescript-purchase"; (global as any).purchaseInitPromise = purchase.init(["xydGameCoin"]);

Then a servcie that loads the products import * as purchase from "nativescript-purchase"; import { Product } from "nativescript-purchase/product";

public loadProducts(){ return new Promise(()=>{ purchase.getProducts().then((products: Array) => { products.forEach((product: Product) => { console.log('HEEEEEERRREEREREREEE'+product.productIdentifier); console.log(product.localizedTitle); console.log(product.priceFormatted);

            });

        });
    });

}

But this block of code never gets the products from the google play store. I am missing something here ? do i have to create a file with the google store key or something?

Before hand thank you.

PeterStaev commented 5 years ago

Hey @ebalestrini , from what I see you are not checking the promise that you have put in the global object, so probably the plugin is not fully initialized when you call you code. So try to use (global as any).purchaseInitPromise.then(() => loadProducts());

PeterStaev commented 5 years ago

No further response so closing this one for now. In case you still have problems, please provide more details.

ebalestrini commented 5 years ago

I have resolve this issue by doing some research; I found this:

This plugin will NOT work if you are running the app under the following scenarios:

Created a release version (--aab) signed and publish it to an alpha version in the play store.

Release it Install in from the google play tester's page Only then the plugin worked fine.