I'm using inApp purchase and I want to change the UI to 'unavailable' if for some reason I'm unable to retrieve the product information from Google or iOS app store.
ionViewDidEnter() {
this.platform.ready().then(async () => {
firebase.auth().onAuthStateChanged(async user => {
this.currentUser = user;
});
this.unavailable = await this.setupProducts();
console.log('available', this.unavailable);
});
}
setupProducts(): Promise<boolean> {
let productWWHS: string;
let productISA: string;
if (this.platform.is('ios')) {
productWWHS = 'prodID';
productISA = 'prodID';
} else if (this.platform.is('android')) {
productWWHS = 'prodID';
productISA = 'prodID';
}
this.inAppPurchase.ready(() => {
this.products.push(this.inAppPurchase.get(productWWHS));
this.products.push(this.inAppPurchase.get(productISA));
if (!this.products[0]) {
return true;
}
});
return false;
}
I'm doing something wrong in this method, it has the error Type 'boolean' is not assignable to type 'Promise'
I'd like to somehow assert that inAppPurchase.get() has returned something but it doesn't return a promise.
Is there a better way to do this?
Any help would be appreciated.