How to use the expo-in-app-purchases.IAPResponseCode.USER_CANCELED function in expo-in-app-purchases

To help you get started, we’ve selected a few expo-in-app-purchases examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github expo / expo / apps / expo-payments / App.js View on Github external
setPurchaseListener(({ responseCode, results, errorCode }) => {
      if (responseCode === IAPResponseCode.OK) {
        for (const purchase of results) {
          console.log(`Successfully purchased ${purchase.productId}`);
          if (!purchase.acknowledged) {
            finishTransactionAsync(purchase, true);
          }
        }
      } else if (responseCode === IAPResponseCode.USER_CANCELED) {
        console.log('User canceled');
      } else {
        console.warn(
          `Something went wrong with the purchase. Received response code ${responseCode} and errorCode ${errorCode}`
        );
      }
    });
  }