React-native-iap: getPurchaseHistory() and getAvailablePurchases() are not resolved / rejected

Created on 17 Apr 2020  路  11Comments  路  Source: dooboolab/react-native-iap

Version of react-native-iap

4.4.4
The issue is reproduced on v 4.4.4 only, the 4.3.0 works like a charm

Version of react-native

0.61.5

Platforms you faced the error (IOS or Android or both?)

iOS

Expected behavior

getPurchaseHistory() and getAvailablePurchases() return purchases

Actual behavior

getPurchaseHistory() and getAvailablePurchases() aren't resolved or rejected

Tested environment (Emulator? Real Device?)

Simulator (13.4), iPhone 8 Plus (13.4), iPhone X (13.4)

Steps to reproduce the behavior

Please see the code below:

  const canMakePayments = await RNIap.initConnection()
  if (!canMakePayments) {
    dispatch(setAvailableIapProductsSuccess(null))
    return
  }
  const products = await RNIap.getProducts(R.consts.IAP_SKUS)
  logger.log('Available IAP: ' + JSON.stringify(products))
  dispatch(setAvailableIapProductsSuccess(products))

  try {
    const pendingPurchases = await RNIap.get()
    logger.log('Pending = ', JSON.stringify(pendingPurchases)) // => works fine

    const availablePurchases = await RNIap.getAvailablePurchases() // => doesn't work
    logger.log('Available purchases = ' + availablePurchases)

    // the app never reaches here

    const purchaseHistory = await RNIap.getPurchaseHistory() // => doesn't work
    logger.log('Purchase history = ' + purchaseHistory)
  } catch (err) {
    logger.log(err)
  }

Does anybody know how to fix that? I checked out the native code, as well as the bridge and all that seems fine.

鈱氾笍 regression

Most helpful comment

@hyochan 4.4.6 works perfectly, thanks a lot

All 11 comments

Have been experiencing the same issue since last night. +1

Looks related to #982. Could you try 4.4.6 and comeback?

Looks resolved now.

@hyochan 4.4.6 works perfectly, thanks a lot

This isn't working for me either in version 4.5.2 (on dev and test-flight). This never returns anything:

            RNIap.getPurchaseHistory().then((history) => {
                updateLog(history, 'history')
            }).catch((ex)=> {
                updateLog(ex, 'history_fail');
            });

            RNIap.getAvailablePurchases().then((history) => {
                updateLog(history, 'available')
            }).catch((ex)=> {
                updateLog(ex, 'available_fail');
            });     

For me it's working after I read this issue... I just update for (version 4.5.3). Perfect. 馃憣

4.5.3 not working for me either.
@dioptre did you resolved this already ? if yes can you please share the steps.

incase anybody still facing this issue please don't forget to initialize connection in component did mount and its safe to end connection when unmount, here are the methods from docs:
RNIap.initConnection(); RNIap.endConnection();

Hey body!

I change for another library. Now I am using RevenueCat.

I am on 5.0.1 and see this issue as well. RNIap.getPurchaseHistory() and getAvailablePurchases() both never resolve nor reject. Any fix out there?

On 5.1.3, It works with initConnection and endConnection

Was this page helpful?
0 / 5 - 0 ratings