score:0

you didn't describe what is going wrong, but here's a basic configuration that works for me on ios.

i'm only including the part about the store:

index.tsx

import { iapproduct, inapppurchase2 } from '@ionic-native/in-app-purchase-2';

const startstoreeventlisteners = () => {
  if (isplatformmobile()) {
    document.addeventlistener(
      'deviceready',
      () => {    
        const store = inapppurchase2;
        // needed to use iap + cordova plugins.

        // set debug messages.
        // default.
        store.verbosity = store.quiet;
        // store.verbosity = store.debug;

        store.register([
          {
            id: submonthly,
            type: store.paid_subscription,
          },
          {
            id: subannual,
            type: store.paid_subscription,
          },
        ]);
    
        // upon approval, verify the receipt.
        store.when(submonthly).approved((product: iapproduct) => {
          product.verify();
        });
        store.when(subannual).approved((product: iapproduct) => {
          product.verify();
        });

        // upon receipt validation, mark the subscription as owned.
        store.when(submonthly).verified((product: iapproduct) => {
          product.finish();
        });
        store.when(subannual).verified((product: iapproduct) => {
          product.finish();
        });
    
        // track all store errors
        store.error((err: error) => {
          debuglog('store error', json.stringify(err));
        });
    
        // https://billing-dashboard.fovea.cc/setup/cordova
        store.validator =
          'https://validator.fovea.cc/v1/validate?appname=secret';
        store.refresh();

        startionic();
      },
      false,
    );
  } else {
    startionic();
  }
};

startstoreeventlisteners();

serviceworker.unregister();

note that @ionic-native packages are deprecated and need to be converted.


Related Query

More Query from same tag