InAppPurchases.purchaseItemAsync() promise sometimes never resolves on iOS

When I call InAppPurchases.purchaseItemAsync() on iOS, the promise sometimes doesn’t resolve (sometimes it will resolve after 20-30seconds). When this happens, I don’t see the Apple purchase confirmation that slides up.

Has anyone ran into this? Seems like this is a similar issue but not much info: InAppPurchases.purchaseItemAsync never resolves

Overall, I am not sure what could cause this. I make sure that I am connected to apple before calling purchaseItemAsync. I am trying to dig into native code and see what hangs and why the confirmation prompt doesn’t show up but that is slow going.

    const connectToApple = async () => {
      try {
        const responseCode = await InAppPurchases.getBillingResponseCodeAsync()
    
        if (responseCode === InAppPurchases.IAPResponseCode.ERROR)
          await InAppPurchases.connectAsync()
      } catch (err) {
        Sentry.captureException(err)
      }
    }
    
    const purchaseSubscription = async () => {
      console.log('PURCHASE_SUB_STARTED')
      try {
        await connectToApple()
        console.log('PURCHASE_SUB_CONNECTED_TO_APPLE')

        await getSubscriptionDetails()
        console.log('PURCHASE_SUB_DETAILS_FETCHED')

        await InAppPurchases.purchaseItemAsync(
          envVars.APPLE_SUBSCRIPTION_PRODUCT_ID,
        )
        console.log('PURCHASE_SUB_COMPLETE')
      } catch (err) {
        console.log('PURCHASE_SUB_FAILED', err)
        Sentry.captureException(
          `Failed to call purchaseItemAsync with product id ${
            self.appleSubscriptionDetails!.productId
          }`,
        )
      }
    }

I get to PURCHASE_SUB_DETAILS_FETCHED and it just hangs. Any help would be greatly appreciated.

Expo diagnostics:

  Expo CLI 3.25.1 environment info:
    System:
      OS: macOS 10.15.7
      Shell: 3.2.57 - /bin/bash
    Binaries:
      Node: 10.23.0 - ~/.nvm/versions/node/v10.23.0/bin/node
      Yarn: 1.21.1 - ~/.yarn/bin/yarn
      npm: 6.14.8 - ~/.nvm/versions/node/v10.23.0/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    IDEs:
      Xcode: 12.2/12B45b - /usr/bin/xcodebuild
    npmPackages:
      react: ~16.11.0 => 16.11.0 
      react-dom: ~16.11.0 => 16.11.0 
      react-native-web: 0.13.3 => 0.13.3 

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.