react-native-iap: buySubscription returns E_UNKNOWN despite successful purchase

Version of react-native-iap

2.2.2 (because any newer version fails on iOS due to #279)

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

iOS

Expected behavior

No error should be thrown. Purchase was successful (live and in production)

Actual behavior

E_UNKNOWN error is returned from Promise Our Sentry.io error tracking reports this:

{"framesToPop":1,"code":"E_UNKNOWN","nativeStackIOS":["0   LuCoaching                          0x000000010062f6fc LuCoaching + 1996540","1   LuCoaching                          0x000000010060aa98 LuCoaching + 1845912","2   LuCoaching                          0x00000001007cad98 __cxa_throw + 438380","3   LuCoaching                          0x00000001007cc62c __cxa_throw + 444672","4   libdispatch.dylib                   0x000000019d078484 <redacted> + 16","5   libdispatch.dylib                   0x000000019d025610 <redacted> + 56","6   LuCoaching                          0x00000001007cc46c __cxa_throw + 444224","7   libdispatch.dylib                   0x000000019d0776c8 <redacted> + 24","8   libdispatch.dylib                   0x000000019d078484 <redacted> + 16","9   libdispatch.dylib                   0x000000019d0249ec <redacted> + 1068","10  CoreFoundation                      0x000000019d5ce1bc <redacted> + 12","11  CoreFoundation                      0x000000019d5c9084 <redacted> + 1964","12  CoreFoundation                      0x000000019d5c85b8 CFRunLoopRunSpecific + 436","13  GraphicsServices                    0x000000019f83c584 GSEventRunModal + 100","14  UIKitCore                           0x00000001ca444bc8 UIApplicationMain + 212","15  LuCoaching                          0x000000010044d110 LuCoaching + 20752","16  libdyld.dylib                       0x000000019d088b94 <redacted> + 4"],"userInfo":{"NSLocalizedDescription":"Verbindung mit iTunes Store nicht möglich"},"domain":"SKErrorDomain","line":26,"column":1877,"sourceURL":"/var/containers/Bundle/Application/818C8439-E250-42E8-AD57-EC4FB5FE5547/LuCoaching.app/main.jsbundle"}

Tested environment (Emulator? Real Device?)

Real Device. Live customers. Very consistenlty fails

Steps to reproduce the behavior

When testing the procedure with Sandbox users the error cannot be reproduced.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 6
  • Comments: 30 (14 by maintainers)

Most upvoted comments

👍 We are experiencing this issue was well. It seems to be happening to about 10% of our users currently. We’re going to try adding this listener, but I don’t think that ultimately this is a great solution. @hyochan Is there any way we can get more detailed information in the cases where this throws, or is that a standard response from the StoreKit APIs? In every error case the message seems to be “Cannot connect to iTunes Store”, even when the purchase is successful.

I’m seeing this error too. And I think I know one way to reproduce it.

Version of react-native-iap

^2.4.1

Version of react-native

https://github.com/expo/react-native/archive/sdk-32.0.0.tar.gz

Platform

iOS, when testing in TestFlight on a real device.

Observations

I noticed that when any RNIap functions were called in my app, iOS would ask me to enter a password for a previous iTunes/App Store user (which I have since logged out and replaced via iOS Settings). I read somewhere online that this is an issue that dogs iPhone users from time to time: sometimes an app is bought with one iTunes account, then the phone is switched to a new iTunes account, but the app continues to ask for the password for the old iTunes account.

I tried to delete my app (and TestFlight) and reinstall with the new App Store user, to no avail. The only way I could get rid of this behavior was to wipe the device. Once I did this, I could no longer reproduce this error.

Actual Behavior

  1. buySubscription()
  2. Select Continue when presented with iOS modal “Subscription Terms”
  3. Select OK when presented with iOS modal “Confirm Subscription”
  4. Error thrown by buySubscription():
{
   code: E_UNKNOWN, 
   column: 1565, 
   domain: NSURLErrorDomain, 
   framesToPop: 1, 
   line: 20, 
   nativeStackIOS: [...],
   sourceURL: ...,
   userInfo: {
      _kCFStreamErrorCodeKey: -4, 
      _kCFStreamErrorDomainKey: 4, 
      NSErrorFailingURLKey: None, 
      NSErrorFailingURLStringKey: https://p100-sandbox.itunes.apple.com/WebObjects/MZFinance.woa/wa/inAppBuy, 
      NSLocalizedDescription: Cannot connect to iTunes Store, 
      NSUnderlyingError: {
         code: "-1005", 
         domain: "kCFErrorDomainCFNetwork", 
         message: "underlying error", 
         nativeStackIOS: [...],
         userInfo:{"NSErrorPeerAddressKey":null,"_kCFStreamErrorCodeKey":-4,"_kCFStreamErrorDomainKey":4}
      }
   }
}

Steps to reproduce the behavior

  1. Create a test user in App Store Connect
  2. Install app from App Store (or invite test user to TestFlight and install TestFlight and then app through TestFlight)
  3. Purchase a subscription in app
  4. Let the subscription expire
  5. Logout iOS Apple ID (Settings > Apple ID, Sign Out)
  6. Login new Apple ID
  7. Purchase a subscription in app

Hope this helps someone!

@dooboolab I still get this issue while using buySubscription() with a sandbox tester user with iPhone 6S.

{"userInfo":{"NSLocalizedDescription":"Cannot connect to iTunes Store"}}

@dooboolab it worked once, but while I tried again I kept getting this errors. (used v 2.3.17)

@hyochan Not works for me.

My test cenario is:

  • Purchase the monthly subscription plan - Ok
  • Upgrade to annual subscription plan - Fails and listener not working

Another doubt: Do I have to use finishTransaction() in subscriptions too ?

Hello,

Same issue behavior with “buyProductWithoutFinishTransaction” or “buyProduct”.

Version 2.2.1

the return stored is { "framesToPop": 1, "code": "E_UNKNOWN", "nativeStackIOS": [...], "userInfo": { "NSLocalizedDescription": "Connexion à l’iTunes Store impossible" }, "domain": "SKErrorDomain", "line": 16, "column": 1599, "sourceURL": "..." }

We updated the module because we reproduce this bug on production with previous versions .