React-native-iap: getAvailablePurchases() does not repond on iOS.

Created on 2 Apr 2019  路  14Comments  路  Source: dooboolab/react-native-iap

Version of react-native-iap

2.4.5

Version of react-native

0.59.3

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

iOS, Xcode 10.2

Expected behavior

getAvailablePurchases() should return any result.

Actual behavior

Does not respond.

Tested environment (Emulator? Real Device?)

Simulator and Real Device(sandbox)

Steps to reproduce the behavior

const subscriptions = await RNIap.getSubscriptions(['sub.id1']);
console.log('subscriptions: ', subscriptions); // It's OK. subscriptions: [ { productId: 'sub.id1', ...
const purchases = await RNIap.getAvailablePurchases();
console.log('Purchases: ', purchases); // Does not respond.

This happens after update Xcode 10.2

馃摫 iOS 馃檹 help wanted 馃毝馃徎 stale

All 14 comments

I might be having the same problem in production (iPhone 6 iOS 11.3.1) ... So this issue is intersting.

Is that possible for you to add break points to RNIapIos.m and see what exactly is happening?
Is either paymentQueueRestoreCompletedTransactionsFinished or restoreCompletedTransactionsFailedWithError called?

I am also curious what is the iOS version of your TestDevice?
It seems iOS 11.3 can be problematic.
https://forums.developer.apple.com/thread/99660

We're having the same problem. At first we thought the issue were only related to restoring after entering promo codes. But in the last couple of days, we're seeing this affecting other users also.

Our original issue: https://github.com/dooboolab/react-native-iap/issues/227

We havn't been able to locate the bug, since the issue is only happening in production.

The issue is seen on a couple of diffrent iOS version. The last time it happen was on a iPhone 8 running 12.1.4

A few weeks ago we implemented sentry and updated our code to the following. But the purchases array are just empty.
``

let purchases = await RNIap.getAvailablePurchases();
Sentry.captureMessage("All purchases:");
Sentry.captureMessage(purchases); // Returns []

@andersmandersen in your case, it seems you are getting an empty response at least. In my case it stucks at that line. Are you calling clearTransactions? If not that might solve your issue.

@bhs324 Can you clarify what "doesn't respond" means? Does it return an empty array or it does not reach that line?

@wasedaigo iOS 12.2. It does not reach that line.

@bhs324 did you set breakpoints..? it would be great if you can find out why it is not moving forward

@wasedaigo paymentQueueRestoreCompletedTransactionsFinished is called and it works now!
But it works only in development mode.

In production mode, getAvailablePurchases still not working.

I runned application with this command, 'react-native run-ios --configuration Release'.

And alert not displaying with this code.

Alert.alert(null, 'Hello!'); // It does not reach! I called BEFORE getAvaliablePurchases.
const purchases = await RNIap.getAvailablePurchases();

After comment out getAvailablePurchases, alert displaying.

Alert.alert(null, 'Hello!');
// const purchases = await RNIap.getAvailablePurchases();

I think you should use Break Point or console log instead of Alert. It is possible this is a bug of Alert itself.

I tested on simulator with these steps.

  1. Set break points on 'paymentQueueRestoreCompletedTransactionsFinished' and 'restoreCompletedTransactionsFailedWithError'.
  2. Calls getAvaiablePurchases like this.
// App.js
  async componentDidMount() {
    await RNIap.getAvailablePurchases();
    // ...
  1. Launch my app and cancel iTunes sign in.
  2. restoreCompletedTransactionsFailedWithError is called.
  3. App freezes.

Here is my workaround to avoid freezing.

// App.js
  async componentDidMount() {
    setTimeout(async() => {
      await RNIap.getAvailablePurchases();
    }, 5000); // set enough delay.
    // ...

I don't think simulator is a good way to test IAP. But, what does restoreCompletedTransactionsFailedWithError return as an error?

Same issue happening to me. getAvailablePurchases() get stuck.
The error occurs on last version [email protected] on iOS version 12.2
It's working for older iOS versions and on Android.
Edit:
It's now working for iOS 12.2 and 12.3 beta. Don't know why.

getAvailablePurchases()
Dosn't work for me
"react-native": "0.59.8"
"react-native-iap": "^2.5.5"
then run on device, show login appleid window, then i input apple id and password, response itunes connect error.

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as "For Discussion" or "Good first issue" and I will leave it open. Thank you for your contributions.

Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please feel free to create a new issue with up-to-date information.

This seems to be the same issue at #981 .

Was this page helpful?
0 / 5 - 0 ratings