dooboolab-community / react-native-iap

In App Purchase module for React Native!
https://react-native-iap.dooboolab.com
MIT License
2.73k stars 629 forks source link

TestFlight not working with In-app purchases #2765

Open G2Patrik opened 2 weeks ago

G2Patrik commented 2 weeks ago

Environment react-native-iap: 12.12.2 react-native: 0.72.12 Platforms (physical & simulator): iPhone 11 - OS version 17.4 /// iOS Simulator iPhone 15 Pro Max - OS version 17.4

Description Hello, I am trying to test the purchase of a subscription and an in-app purchase within my react native app. I have setup the necessary Sandbox account in App Store Connect, created a Store kit file in Xcode that I also synced with the products I created in the App Store Connect dashboard.

If I use Xcode to run the app on a physical device (after logging into the sandbox account), I am able to purchase a subscription/in-app product without any issues. If I purchased a subscription on the physical phone I can go into Settings > App Store > Sandbox Account Management and see the purchased subscription, change renewal rate, clear purchase history etc..

If I use the TestFlight build with a physical phone (logging in with the sandbox account) the in app purchases stop working correctly. After purchasing a subscription it is not shown in the Sandbox Account Management, so I am unable to cancel it. Upon trying to purchase another subscription the apple service keeps returning the same exact subscription that I "originally" purchased. How am I supposed to cancel that subscription if it not shown in the sandbox account subscription list? Adding a different sandbox account does not help either, trying to purchase another subscription returns the same subscription that I am unable to cancel. Is there a step in the TestFlight environment that I am missing on setup?

Expected Behavior Upon purchasing a subscription in the TestFlight environment on a physical device I should be able to cancel that subscription.

const product = { productId: 'example_monthly_subscription' };
subscribe(product.productId);

Any help would be appreciated.

Kavosh-m commented 2 weeks ago

I have the same problem

hyochan commented 2 weeks ago

Debugging this issue is a bit challenging for me at the moment. However, I asked ChatGPT for assistance, and this is the response I received. Could this be helpful?

Response from ChatGPT:

The issue you're experiencing with in-app purchases in the TestFlight environment is likely due to some specific behaviors and limitations associated with TestFlight and Sandbox environments. Here are some steps and checks you can perform to troubleshoot and potentially resolve the issue:

  1. Ensure Correct Sandbox Account Usage:

    • Double-check that you are logged into the correct Sandbox account on your physical device when using the TestFlight build.
    • Go to Settings > App Store > Sandbox Account Management to verify the account details.
  2. Reset Sandbox Account Data:

    • Sometimes, Sandbox account data can become corrupted. To reset it:
      1. Log out of the Sandbox account on the device.
      2. Restart the device.
      3. Log back into the Sandbox account and try the purchase again.
  3. Check App Store Connect Configurations:

    • Ensure that your in-app purchase products are correctly configured and approved in App Store Connect.
    • Verify that the StoreKit configuration file in Xcode matches the product IDs configured in App Store Connect.
  4. Review Subscription Handling Code:

    • Ensure your subscription handling logic is correctly implemented in the app. Pay attention to how you handle the purchase response and the state of the subscription.
  5. Clear TestFlight Cache:

    • Sometimes TestFlight builds can cache old data. Reinstalling the app from TestFlight can help:
      1. Delete the app from the device.
      2. Reinstall the app from TestFlight.
      3. Log into the Sandbox account and attempt the purchase again.
  6. Check for Known Issues:

Additional Debugging Steps:

  1. Review Apple Documentation:

  2. Apple Developer Forums:

    • Consider posting your issue on the Apple Developer Forums for additional insights and potential solutions from the developer community.

By following these steps, you should be able to identify and resolve the issue with in-app purchases not working correctly in the TestFlight environment. If the issue persists, providing detailed logs and steps you've taken when reaching out for support will be helpful.