Reputation: 31
I would appreciate any help setting up this plug in:
https://github.com/PeterStaev/nativescript-purchase
I have set up a test product in the google play store console. My app's package is the same in the console and my app. I have put installed the plugin and try this code on my home controller:
import * as purchase from "nativescript-purchase";
(global as any).purchaseInitPromise = purchase.init(["xydGameCoin"]);
//Then load 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(product.productIdentifier);
console.log(product.localizedTitle);
console.log(product.priceFormatted);
});
});
});
}
But this block of code never gets the products from the google play store. The error is that the getProducts()
method does not exist because purchase
is undefined.
I am missing something here? do i have to create a file with the google store key or something?
Upvotes: 2
Views: 387
Reputation: 31
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:
- In an emulator (generally google services are disabled.)
- Without signature in a normal phone
- In a phone that has not enabled google payments on the google play store.
Then how did i make it run?
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.
Upvotes: 1