react-native-purchases icon indicating copy to clipboard operation
react-native-purchases copied to clipboard

Purchases.getProducts() hangs

Open theianjohnson opened this issue 1 year ago • 16 comments

Describe the bug A clear and concise description of what the bug is. The more detail you can provide the faster our team will be able to triage and resolve the issue. Do not remove any of the steps from the template below. If a step is not applicable to your issue, please leave that step empty.

  1. Environment
    1. Platform: Android
    2. SDK version: 7.27.0
    3. OS version: 14.4 (23E214)
    4. Xcode/Android Studio version: 2023.1.1 Patch 1
    5. React Native version: 0.73.6
    6. SDK installation (CocoaPods + version or manual): Expo 50.0.17
    7. How widespread is the issue. Percentage of devices affected. 100%, both simulator and real Android device
  2. Debug logs that reproduce the issue: Same as https://github.com/RevenueCat/react-native-purchases/issues/832 I've set Purchases.setLogLevel(Purchases.LOG_LEVEL.DEBUG); but nothing's ever actually logged (ongoing issue seemingly unrelated)
  3. Steps to reproduce, with a description of expected vs. actual behavior
  4. Other information (e.g. stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, etc.)

Additional context I had a purchase in February and haven't changed anything in RevenueCat or the Play Store since then so it's seemingly something code

        Purchases.setLogLevel(Purchases.LOG_LEVEL.DEBUG); // Doesn't seem to do anything
        if (Platform.OS == "android") {
          console.log('  Android', Constants.expoConfig.extra.revenueCatGoogleApiKey, anonymousUserId);
          Purchases.configure({ apiKey: Constants.expoConfig.extra.revenueCatGoogleApiKey, appUserID: anonymousUserId });
        } else {
          console.log('  Apple', Constants.expoConfig.extra.revenueCatAppleApiKey, anonymousUserId);
          Purchases.configure({ apiKey: Constants.expoConfig.extra.revenueCatAppleApiKey, appUserID: anonymousUserId });
        }

        // Above console.log's output correctly

        const productIds = Object.values(Constants.expoConfig.extra.products[Platform.OS]);
        console.log('Fetching products with IDs:', productIds); // Output's correctly (also works in iOS)
        try {
          const products = await Purchases.getProducts(productIds); // Hangs?
          console.log('Products fetched:', products); // Never logs
          setProducts(products);
        } catch (error) { // Nothing ever happens here either
          console.error('Failed to get products', error);
          Sentry.captureException(error);
        }

theianjohnson avatar Apr 30 '24 02:04 theianjohnson

👀 We've just linked this issue to our internal tracker and notified the team. Thank you for reporting, we're checking this out!

RCGitBot avatar Apr 30 '24 02:04 RCGitBot

I've set Purchases.setLogLevel(Purchases.LOG_LEVEL.DEBUG); but nothing's ever actually logged (ongoing issue seemingly unrelated)

There's nothing in the logcat? We are going to need those logs to be able to understand what's going on with getProducts. I sometimes need to unplug and plug my device to see logs in logcat.

vegaro avatar Apr 30 '24 09:04 vegaro

Just learned logcat is a thing inside Android Studio (I was expecting terminal output) and there are errors which seem to point to billing

In-app billing API version 3 is not supported on this device.
2024-04-30 07:15:36.095  4937-4937  [Purchases] - ERROR     com._____._____            E  🤖‼️ PurchasesError(code=StoreProblemError, underlyingErrorMessage=Billing is not available in this device. Make sure there's an account configured in Play Store. Reopen the Play Store or clean its caches if this keeps happening. Original error message: DebugMessage: Google Play In-app Billing API version is less than 3. ErrorCode: BILLING_UNAVAILABLE., message='There was a problem with the store.')
2024-04-30 07:15:37.048  4937-4937  BillingClient           com._____._____            W  Billing service disconnected.
2024-04-30 07:15:37.051  4937-4937  [Purchases] - WARN      com._____._____            W  ⚠️ Billing Service disconnected for com.android.billingclient.api.BillingClientImpl@fb5775b

I think two questions - why would this cause the call to hang? And the same issue is happening in my live app on an Android device that I am logged into the play store with and has my credit card attached.

theianjohnson avatar Apr 30 '24 14:04 theianjohnson

Hey @theianjohnson I'm not sure why that error would cause getProducts to hang (maybe @vegaro can chime in) but the In-app billing API version 3 is not supported on this device. error comes straight from Google Play and not RevenueCat. Can you try clearing data and force stopping the Google play app?

mshmoustafa avatar May 02 '24 16:05 mshmoustafa

@mshmoustafa I've tried clearing Google Play cache and data, tried multiple devices, all the same hang with getProducts(). In all the same environments getOfferings() works fine so that's what I'm now reimplementing everything with, seems getProducts() is just buggy

theianjohnson avatar May 04 '24 16:05 theianjohnson

That's very strange. getOfferings pretty much does the same as getProducts, meaning they interact with Google in the same way, and it doesn't make much sense one is giving In-app billing API version 3 is not supported on this device. and the other one is not.

Do you mind sharing the full logcat?

Also, we would appreciate if you have a minimal reproducible project you can share with us so we can try to reproduce on our side.

Thanks!

vegaro avatar May 06 '24 09:05 vegaro

Hi, I am having the same issue. Is there any update on this or is it recommended to use getOfferings instead?

c-lamont avatar May 22 '24 14:05 c-lamont

I can confirm that using getOfferings works while getProducts does not on Android.

c-lamont avatar May 23 '24 15:05 c-lamont

@c-lamont sorry for the delay, can you open a new issue with the requested environment details and the logcat for when getProducts fails?

mshmoustafa avatar Jun 18 '24 02:06 mshmoustafa

this also hangs btw await Purchases.logIn(userIdentifier)

Technickster avatar Jul 23 '24 04:07 Technickster

I can confirm that using getOfferings works while getProducts does not on Android.

cleversonhabiitech avatar Jul 30 '24 12:07 cleversonhabiitech

I noticed that for Android, I have to use the value up to the : instead of the full path of the Products to get it.

For example Pass "premium-plan" to getProducts instead of "premium-plan:1month".

sakutaro220 avatar Aug 10 '24 15:08 sakutaro220