Skip to content

In App Purchase: Subscriptions products on iOS 18.5 Simulators not showing but shows on real devices 18.5 #1659

@bevinGithub

Description

@bevinGithub

In App Purchase: Subscriptions products on iOS 18.5 Simulators not showing but shows on real devices 18.5

Hi everyone, lm having an issue with my In App Purchase to handle subscriptions payments. Everything is working on iOS 18.2 , 18.4 simulators and i have upgraded my Xcode to 16.4 to cater for iOS 18.5 simulators and I cannot get products from the store its returning empty. I did further investigation and l am getting its giving an error code

Anyone having the same issue on iOS 18.5 i am stuck as the review process is rejecting my app is there a bug or new way of doing subscriptions on iOS 18.5

Below is my environment

Ionic:

Ionic CLI : 7.2.1 (/usr/local/lib/node_modules/@ionic/cli)
Ionic Framework : @ionic/angular 8.4.3
@angular-devkit/build-angular : 19.2.0
@angular-devkit/schematics : 19.2.0
@angular/cli : 19.2.0
@ionic/angular-toolkit : 12.1.1

Capacitor:

Capacitor CLI : 7.1.0
@capacitor/android : 7.1.0
@capacitor/core : 7.2.0
@capacitor/ios : 7.2.0

Utility:

cordova-res : 0.15.4
native-run : 2.0.1

System:

NodeJS : v20.18.3 (/usr/local/bin/node)
npm : 10.8.2
OS : macOS Unknown

**Sample Code TS File **

onDeviceReady() {
this.platform.ready().then(() => {
const { store, ProductType, Platform } = CdvPurchase;
store.verbosity = CdvPurchase.LogLevel.DEBUG;
store.register(
[
{
id: this.freeMonthly,
type: ProductType.PAID_SUBSCRIPTION,
platform: Platform.APPLE_APPSTORE,
},
{
id: this.standardMonthly,
type: ProductType.PAID_SUBSCRIPTION,
platform: Platform.APPLE_APPSTORE,
},
{
id: this.standardAnnual,
type: ProductType.PAID_SUBSCRIPTION,
platform: Platform.APPLE_APPSTORE,
},
{
id: this.familyX2Monthly,
type: ProductType.PAID_SUBSCRIPTION,
platform: Platform.APPLE_APPSTORE,
},
{
id: this.familyX2Annual,
type: ProductType.PAID_SUBSCRIPTION,
platform: Platform.APPLE_APPSTORE,
},
{
id: this.familyX5Monthly,
type: ProductType.PAID_SUBSCRIPTION,
platform: Platform.APPLE_APPSTORE,
},
{
id: this.familyX5Annual,
type: ProductType.PAID_SUBSCRIPTION,
platform: Platform.APPLE_APPSTORE,
},
]);

  store.initialize().then((data: any) => {
    this.product = store.get(this.iosSubscriptionID); 
    this.ref.detectChanges();
    this.setProductListeners();
  }, (err: any) => {
    console.log(err);
  })
})

}

setProductListeners() {
CdvPurchase.store.when().approved((transaction: any) => {
transaction.verify();
console.log("==============STEP APPROVED===================");
});

CdvPurchase.store.when().verified((verifiedReceipt: any) => {
  verifiedReceipt.finish();
  // CdvPurchase.store.findInLocalReceipts(this.iosSubscriptionID)
  console.log("==============VERIFIED RECEIPT===================");
  console.log("Verified Receipt: ", verifiedReceipt); 
  console.log("==============END OF VERIFIED RECEIPT===================");
});

CdvPurchase.store.when().finished((finished: any) => {
  console.log("==============FINISHED STEP===================");
  console.log("FINISHED DATA: ", finished);
  console.log("==============FINISHED STEP===================");
  finished.finish();
  const subscriptionData = {
    userID: this.loggedUser.id,
    email: this.loggedUser.email,
    iosID: this.iosSubscriptionID,
    planID: this.productID,
    orderID: 'testOrderID',
    purchaseToken: 'TransAppleID',
  };
  console.log(subscriptionData);
  console.log("Status of Transaction: ", this.isProcessingTransaction);
  if (this.isProcessingTransaction === true) {
    this.presentLoading();
    this.storage.set('subscriptionData', subscriptionData);
    this.isProcessingTransaction = false;
    console.log("Status of Transaction: ", this.isProcessingTransaction);
    this.router.navigate(['/payment-success']);
  }
});

CdvPurchase.store.when().receiptUpdated((receipt: any) => {
  console.log("==============RECEIPT STEP===================");
  console.log("Receipt Data", receipt);
  console.log("Status of Transaction: ", this.isProcessingTransaction);
  console.log("==============RECEIPT STEP===================");
  
  if (receipt?.nativeData !== undefined) {
    this.receiptDetails = receipt?.nativeData;
    const appStoreReceipt = this.receiptDetails?.appStoreReceipt;
    const postReceipt = {
      receiptData: appStoreReceipt
    }
    this.presentLoading();
    this.http.post(this.url + 'verify-apple-receipt-2.php', postReceipt).subscribe({
      next: (res: any) => {
        console.log("VALIDATE RETURN DATA: ", res);
      }, 
      error: (err: any) => {
        console.log(err);                
      }
    })
  }
  
  // CdvPurchase.store.
  if (CdvPurchase.store.owned(receipt)) {
    this.flashNotice('Subscription is already active!');
  }
});

CdvPurchase.store.when().productUpdated(() => {
    console.log("==============UPDATE PRODUCT & UI===================");
    this.ref.detectChanges();
});

CdvPurchase.store.error((error: any) => {
  if (this.error?.isError === true && this.error?.message === "ITEM_ALREADY_OWNED") {
    this.isProcessingTransaction = false;
    this.flashNotice(`You are already subscribed to ${ this.product?.title}`);
  } else {
    console.log(error);
    this.isProcessingTransaction = false;
  }
});

}

async storageInit() {
await this.storage.create();
}

getCurrentUser() {
this.currentUser = this.storage.get('currentUser');
return this.currentUser;
}

async subscribe(data: any) {
this.presentLoading();
const { store, Platform, ProductType, } = CdvPurchase;
const appleProduct = data?.productID;
const product = store.get(appleProduct, Platform.APPLE_APPSTORE);

const offer = product?.getOffer();
this.offerData = product?.offers;

if (appleProduct === 'free_trial_') {
  const offerProduct = product?.getOffer(product.platform == CdvPurchase.Platform.APPLE_APPSTORE ? "$" : undefined); 
  if (offerProduct && this.details?.subscriptionID !== 'free_trial_') {
    const purchaseResult =  await offerProduct.order();
    if(purchaseResult?.isError) {
      this.isProcessingTransaction = false;
      this.flashNotice(purchaseResult?.message);  
    }
    this.isProcessingTransaction = true;
  } else {
    this.isProcessingTransaction = false;
  }
} else {
  //NOT FREE OFFER
  if (appleProduct !== this.details?.subscriptionID) {
    if (offer) {
      this.isProcessingTransaction = true;
      offer.order();
    } else {
      this.isProcessingTransaction = false;
    }
  } else {
    this.isProcessingTransaction = false;
  }
}

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions