question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

getPurchaseHistory() and getAvailablePurchases() are not resolved / rejected

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
n0umankhancommented, Sep 12, 2020

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();

2reactions
zoftifycommented, Apr 18, 2020

@hyochan 4.4.6 works perfectly, thanks a lot

Read more comments on GitHub >

github_iconTop Results From Across the Web

React Native: RNIap.getPurchaseHistory().then runs infinately
After pulling this commit, I deleted my node_modules and pods, and cleaned my build folder, but the askForPurchase() and buyProduct() functions ...
Read more >
react-native-iap - npm
Once an item is consumed, it will no longer be available in getAvailablePurchases() and will only be available via getPurchaseHistory() .
Read more >
dooboolab/react-native-iap (Raised $40.00) - Issuehunt
Task :react-native-iap:compileReleaseJavaWithJavac FAILED ... getPurchaseHistory() and getAvailablePurchases() are not resolved / rejected.
Read more >
react-native native module for In App Purchase
getAvailablePurchases(), Promise<Purchase[]>, Get all purchases made by the user (either non-consumable, or haven't been consumed yet.
Read more >
Check subscription validity using flutter_inapp_purchase ...
[Solved]-Check subscription validity using flutter_inapp_purchase dependency?-Flutter ... getAvailablePurchases() ); for (var purchase in purchases!)
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found