I recently made some package update on my Ionic capacitor application.
Now however when I try to make a purchase I get the following error;
TypeError: n.store.when(...).registered is not a function
this stems from my subscription page when a user click the buy button, here is some of the class:
constructor(
public platform: Platform,
private purchases: Purchases,
private store: InAppPurchase2,
private conversion: DateTimeConversions,
protected authService: AuthenticationService,
protected network: Network
) {
platform.ready().then(async () => {
await this.authService.getStoredUuid().then(async useruuid => {
this.userUUID = useruuid;
});
// this.purchases.setDebugLogsEnabled(true); // Enable to get debug logs
await this.getCurrentSubscriptionInfo();
this.setCurrentPlatform();
});
}
public buySubscription(productID) {
console.log('wqqwfwfwfwffffqfef');
console.log(this.store);
this.platform.ready().then(async () => {
console.log('aaaaaaaaaa');
console.log(this.store);
// After platform ready
this.store.verbosity = this.store.DEBUG;
this.store.register({
id: productID,
type: this.store.PAID_SUBSCRIPTION,
});
// Register event handlers for the specific product
this.store.when(productID).registered((product: IAPProduct) => {
// console.log('Registered: ' + JSON.stringify(product));
});
// Updated
this.store.when(productID).updated(async (product: IAPProduct) => {
await new Promise(r => setTimeout(r, 2000));
await this.getCurrentSubscriptionInfo();
});
// User closed the native purchase dialog
this.store.when(productID).cancelled((product) => {
// console.error('Purchase was Cancelled');
});
// Track all store errors
this.store.error((err) => {
// console.error('Store Error ' + JSON.stringify(err));
});
// Run some code only when the store is ready to be used
this.store.ready(() => {
});
// Refresh the status of in-app products
this.store.refresh();
// To make a purchase
this.store.order(productID).then(r => {
});
})
}
here is my package.json:
"@awesome-cordova-plugins/purchases": "^6.4.0",
"@ionic-native/in-app-purchase-2": "^5.36.0",
"cordova-plugin-purchase": "^13.6.0",
"cordova-plugin-purchases": "^4.6.1",
I think I included the relevant packages.
Would be great if someone could help with this.
Thanks