'Cordova Plugin Purchase - redirect after successful subscription

I am using this plugin (https://github.com/j3k0/cordova-plugin-purchase) to handle a in app subscription.

iap.validator = "https://validator.fovea.cc/v1/validate?appName=XXX";

  //initiate initInAppPurchase function 
  useEffect(() => {
      const init = async () => {
          await initInAppPurchase();
      }
      init();

  }, []);

  //if on an ios or android device, then get product info 
  const initInAppPurchase = () => {
      if ((isPlatform('ios')) || (isPlatform('android'))) {
          iap.verbosity = iap.DEBUG;

          iap.register({
              id: "tpmonthly",
              alias: "Monthly",
              type: iap.PAID_SUBSCRIPTION
          });

          iap.ready(() => {
              let product = iap.get('Monthly');
              setPrice(product.price)
              setProduct(product)
          })

          iap.refresh();

      }
  }

  //if user clicks purchase button 
  const purchaseProduct = () => {
      if (product.owned) {
          alert('A subscription is currently active.')
      } else {
          iap.order('Monthly').then(() => {
              iap.when("tpmonthly").approved((p: IAPProduct) => {
                  p.verify();
              });
              iap.when("tpmonthly").verified((p: IAPProduct) => {
              p.finish();
              history.push("/ios-signup/");
              });
          })
      }
  }

return (
<Button size="large" variant="outlined" onClick={purchaseProduct}>Subscribe Monthly for {productPrice}</Button>
);

What I am hoping to get is that once the subscription is verified that it then redirects the app to /ios-signup/ .. this is not happening.

Is this code correct? And why would it not redirect after p.finish?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source