React-native-iap: iOS 14: getProducts() Unknown Error (RN 0.62.2 - 0.63)

Created on 18 Sep 2020  ·  50Comments  ·  Source: dooboolab/react-native-iap

RNIap.getProducts() appears to be broken in the latest version of React Native, only returning an unknown error.

Version of react-native-iap

4.6.1

Version of react-native

0.63.0

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

iOS

Expected behavior

products to be fetched.

Actual behavior

unknown error being returned

Tested environment (Emulator? Real Device?)

iOS Simulator

Steps to reproduce the behavior

Just call RNIap.getProducts() or RNIap.getSubscriptions().

📱 iOS 🙏 help wanted

Most helpful comment

All 50 comments

I am experiencing this also with iOS simulators running iOS 14.0 but not having issues with other simulator versions (specifically, iOS 13.5).

This appears to be an issue on Apple's end with iOS 14.0 simulator: https://developer.apple.com/forums/thread/125164

Found that link via: https://github.com/dooboolab/react-native-iap/issues/1091

Thanks @joeyscarim. I have now reached out to Apple and awaiting feedback from them.

@rossbulat same issue on iOS 14...
react-native-iap - v4.6.1
Xcode - v12

YellowBox.js:71 Possible Unhandled Promise Rejection (id: 0): Error: UNKNOWN_ERROR Error: UNKNOWN_ERROR at Object.fn [as getItems] (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:2165:36) at http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:179261:33 at step (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:178999:21) at Object.next (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:178929:16) at http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:178901:69 at tryCallTwo (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:3277:7) at doResolve (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:3441:15) at new Promise (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:3300:5) at __awaiter (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:178880:12) at ios (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:179258:16)

Hi everyone,

We are also experiencing this. After upgrade to v4.6.1 almost every time we experience the "unknown error" too.

Screenshot 2020-09-23 at 09 53 25

Hey guys,
I think I found the solution to our issue. You have to be sure that the initConnection is running.
In my example I just put requestPurchase/requestSubscription inside the initConnection. Before it was working without it, now It's a must have.

@Hellhiem I have initConnection and still receiving the error.

Running the following function verifies that the error is still there with initConnection()

  const getProducts = async () => {
      try {
        await RNIap.initConnection();
        const products: RNIap.Product[] = await RNIap.getProducts(IAP_SKUS);
      } catch (err) {
        console.log(err);
      }
  }

@rossbulat what happens when you try this:

const getProducts = async () => {
    return RNIap.initConnection().then(() => {
      try {
        const products: RNIap.Product[] = RNIap.getProducts(IAP_SKUS);

        return products;
      } catch (err) {
        console.log(err);
      }
    });
  };

I made the same thing but inside then I put requestPurchase/requestSubscription

@Hellhiem Still getting Unknown Error! (this is the same as my code but using then instead of async / await syntax).

I've taken a look at the native module APIs, the getItems() function seems to be the point of failure. Is it possible for one of the core devs to verify this native API call is working as expected on iOS 14?

@Hellhiem I have tried your code, still getting same Unknown Error.

Apple engineering are looking into the case via Feedback Assistant. I will update this thread as and when we determine what the problem is.

I am experiencing this issue on iOS simulator running iOS 14.0

Same issue. IOS 14 simulator with xcode 12 can not fetch products and throw unknown error

Same issue.

Same issue for real device during apple review

I have the same issue but with getSubscriptions function

I did some tests and, to me, [[SKProductsRequest alloc] initWithProductIdentifiers:productIdentifiers] just returns empty...

same issue

Have the same issue with getSubscriptions on the IOS side, UNKNOWN_ERROR was thrown, Xcode 12.0, react-native 0.62.2

@rossbulat any luck? I am running into the same issue also

@rossbulat any luck? I am running into the same issue also

Are you using device or simulator?

Hello devs I resolved it. I did the following

  1. I ensured I accepted all terms and conditions in user agreements by making sure the status is active
  2. I ensured that product/subscription Id in in-app-purchases section of your app is marked ready to submit

PS: My test was on a local device

The issue is solely on the iOS 14 Simulator. Real devices work.

Apple have gone quiet over the last week, no updates have been shared with me.

For simulator you should to add StoreKit configuration file to project and select it in you Run scheme. But I had this error on device

The issue is solely on the iOS 14 Simulator. Real devices work.

Apple have gone quiet over the last week, no updates have been shared with me.

Probably testing in app purchases is now restricted to real devices, because I can't find the option to add a sandbox tester on the iOS simulator

The issue is solely on the iOS 14 Simulator. Real devices work.

Apple have gone quiet over the last week, no updates have been shared with me.

Probably testing in app purchases is now restricted to real devices, because I can't find the option to add a sandbox tester on the iOS simulator

It's managed by storekit configuration file

@ilyasbat I followed these instructions, clean build folder and re-build, but unfortunately still getting the error.

i solved by strorekit config.
https://stackoverflow.com/questions/58020258/requesting-an-in-app-purchase-in-ios-13-fails/58065711#58065711

Adding the storekit config file, re-build and now running on the IOS 14 simulator with xcode 12. It works perfectly and I can actually purchase items on the simulator for the first time ever.

@ilyasbat is this fix safe? What will happen if I change my product offers in appstore afterwards, for example change the pricing - will they also get updated in the app or will the app be stuck with the storeConfiguration.storekit config?

@ilyasbat is this fix safe? What will happen if I change my product offers in appstore afterwards, for example change the pricing - will they also get updated in the app or will the app be stuck with the storeConfiguration.storekit config?

Found this really good article:
https://www.appcoda.com/storekit-testing/

From what I'm reading, it looks like the StoreKit configuration-file is for debugging/testing only:

The next field is the Price of the in-app purchase. Even though there are price tiers in App Store Connect, here we can provide any value we want as a free text. The price is just for testing reasons, it won’t apply to the real in-app purchases and of course, there will be no charging. So feel free to set any price you’d like. For this specific in-app purchase that we’re configuring here, 0.99 value is just fine. The currency of the price will be the currency matching to the Simulator’s locale, or any locale that has been manually selected (we’ll talk about that later). So, 0.99 can be dollars, euros, yen, and so on.

I'm not sure if this is known yet (I didn't see it mentioned above): I've found that I keep getting Error: UNKNOWN_ERROR when I run npx react-native run-ios from the terminal, but when I run the app from xcode, the in-app purchase (with storekit) works fine.

"react-native": "0.61.4",
"react-native-iap": "^4.6.3",

xcode v12
macos 10.15.7

At present, it is therefore not possible to use react-native-iap in production on a device with iOS 14? Since the only way to fix the [Error: UNKNOWN_ERROR] is to add a Configuration.StoreKit file, but only for test purposes, not for a production release?

Does anyone have another solution?

I currently use this lib for in-app purchasing in production, Android and iOS (so yes iOS 14). I was able to have users successfully test in TestFlight (note: they can't use fingerprint signin, they have to ender apple id & password always - which is an Apple policy, not a flaw of this library) and things are working in production.

Have you tried testing your app in TestFlight @RobinChailley ?

I got 2 of my real devices on IOS 14.1 working with sandbox accounts again doing the following.

Follow the steps to create the StoreKit configuration, select it in you Run scheme, and then build to your device. Not sure if this step is needed but fetch some products. You can make a purchase at this point but the purchase listener will error out since the transactionId from purchases are "0".

Next deselect the StoreKit configuration from the Run scheme and build to your device again. This time when you fetch products, you will be prompted to login. For some reason, I am able to login with my sandbox accounts now. Not sure why but maybe it clears or resets something.

@karltaylor Yes I got my in-app-purchases to appear when testing in TestFlight. My code looks something like this:

try {
    IAP.initConnection()
        .then((success) => {
            if (!success) return Promise.reject("Failed to connect");

            // get products that can be purchased in iap store
            // Note: this is necessary for requestPurchase to work!
            const productIds = [PRODUCT_ID];
            return IAP.getProducts(productIds);
        })
        .then((prods) => {
            // get already-purchased items
            return getAvailablePurchases();
        })
        .then((purchases) => {
            // continue...
        })
}

Note: my PRODUCT_ID matched the text in "Product ID" column in _appstoreconnect -> App Store -> Manage_

What's the "Status" of your In-App-Purchase(s) in _appstoreconnect_?

@karltaylor Yes I got my in-app-purchases to appear when testing in TestFlight. My code looks something like this:

try {
    IAP.initConnection()
        .then((success) => {
            if (!success) return Promise.reject("Failed to connect");

            // get products that can be purchased in iap store
            // Note: this is necessary for requestPurchase to work!
            const productIds = [PRODUCT_ID];
            return IAP.getProducts(productIds);
        })
        .then((prods) => {
            // get already-purchased items
            return getAvailablePurchases();
        })
        .then((purchases) => {
            // continue...
        })
}

Note: my PRODUCT_ID matched the text in "Product ID" column in _appstoreconnect -> App Store -> Manage_

What's the "Status" of your In-App-Purchase(s) in _appstoreconnect_?

Sorry @Beamanator I removed my comments to avoid causing more confusion as It was an issue with another area.

After adding the Configuration.storekit file I had them working in my simulator and in Testflight! 👍

@rossbulat Were you able to find a solution for this issue? I am getting problem on both Android and ios.

I'm not sure if this is known yet (I didn't see it mentioned above): I've found that I keep getting Error: UNKNOWN_ERROR when I run npx react-native run-ios from the terminal, but when I run the app from xcode, the in-app purchase (with storekit) works fine.

"react-native": "0.61.4",
"react-native-iap": "^4.6.3",

xcode v12
macos 10.15.7

Its fine with me
"react-native": "0.63.2",
"react-native-iap": "^5.1.3",
xcode v12
macos 11.0.1

it worked like this in debug mode, but not in testflight. Would it have a different configuration?

I'm still getting same "Unknown Error" on iOS.

"react-native": "^0.63.4",
"react-native-iap": "^5.2.0",

Xcode 12.2

Any idea to solve this problem without using StoreKit configuration?

I'm still getting same "Unknown Error" on iOS.

"react-native": "^0.63.4",
"react-native-iap": "^5.2.0",

Xcode 12.2

Any idea to solve this problem without using StoreKit configuration?

What version of the simulator did you use ?
Same problem with iOS 14.2 and works fine with iOS 13.5

Same to me when running on simulator iOS 14.2 and works fine with simulator iOS 13.x.

And i have the same problem with Apple validation team, i think they are running my app on a simulator...

We found that your in-app purchase products exhibited one or more bugs when reviewed on iPad running iOS 14.0.1 on Wi-Fi.

  • Launched the app
  • Tapped on the Settings, top left
  • Tapped on Remove ads
  • The app started to load indefinitely

Someone here have already tried to publish non-consumable in-app purchase in production?

Same to me when running on simulator iOS 14.2 and works fine with simulator iOS 13.x.

And i have the same problem with Apple validation team, i think they are running my app on a simulator...

We found that your in-app purchase products exhibited one or more bugs when reviewed on iPad running iOS 14.0.1 on Wi-Fi.

  • Launched the app
  • Tapped on the Settings, top left
  • Tapped on Remove ads
  • The app started to load indefinitely

Someone here have already tried to publish non-consumable in-app purchase in production?

you also have delays in approving prices and apple does not approve your application because you can't buy?

I've made my all my test on real device with a sandbox user. All works to buy the product but Apple refuse my build because of "UNKNOW PRODUCT" error on simulator (iOS 14).

I'm trying to publish this app version with a non-consumable in-app purchase to the App Store since october...

I've made my all my test on real device with a sandbox user. All works to buy the product but Apple refuse my build because of "UNKNOW PRODUCT" error on simulator (iOS 14).

I'm trying to publish this app version with a non-consumable in-app purchase to the App Store since october...

Take a look at our issue.

https://github.com/dooboolab/react-native-iap/issues/1200

I also went through the same problem and had my application released after three weeks.

I've made my all my test on real device with a sandbox user. All works to buy the product but Apple refuse my build because of "UNKNOW PRODUCT" error on simulator (iOS 14).
I'm trying to publish this app version with a non-consumable in-app purchase to the App Store since october...

Take a look at our issue.

1200

I also went through the same problem and had my application released after three weeks.

My build was accepted by Apple, thanks a lot for your help!!!

i answered it here

try on real device

Answer

Having this problem as well on IOS 14 simulators. Would be nice to test payments without having to use a real device.

Not working with this environment

  • Mac 11.2
  • Xcode 12.4
  • Simulator running iOS 14 and above

Working with this environment

  • Mac 11.2
  • Xcode 12.4
  • Simulator running iOS 13.7 and below

On simulator iOS 14 this is working
https://stackoverflow.com/questions/58020258/requesting-an-in-app-purchase-in-ios-13-fails/58065711#58065711

Was this page helpful?
0 / 5 - 0 ratings