StoreKit Always Failing (Not on iOS 12) (Sandbox)

Hello, thank you for your time.

I have run into a problem, which is effecting some of my customers. It seems like StoreKit is having trouble connecting to app store.

My code is this


func bounceStartSubscriptionPurchase() {
   
  EventLogger.shared.logEvent(type: "Subscription", name: "StartSubscription")
   
  isActive = true
  
isPurchasing = true
  _isRestoring = false
   
  if let oldRequest = productsRequest {
    //If the old request is still alive, kill it
    oldRequest.cancel()
    oldRequest.delegate = nil
    productsRequest = nil
  }
   
  StoreManager.postNotification(.purchaseBegin)
   
  productsRequest = SKProductsRequest(productIdentifiers: ["hidden"])
  productsRequest!.delegate = self
  productsRequest!.start()
}

It works fine on my iPhone 5 with iOS 12. With my iPhone X on iOS 13.x, it is failing. Restore purchases seems to at least prompt for a login. The regular purchase will not even prompt for a login if I am not signed in (on sandbox or normal account) - it simply fails in less than 1 second.

Error is this:
Failed Error: Cannot connect to iTunes Store

Some printouts:
canMakePayments = true
does have product = true
request <SKProductsRequest: 0x281c3a300>
requestDidFinish
Update Transaction
Failed Error: Cannot connect to iTunes Store
  • --- Transaction => Failed

Receipt Seconds Passed: 243.54082906246185
It is difficult to follow what you are describing.
But if you do not DELETE the old (production) app from the device before loading the app from Xcode then you will get that error.


Whenever I hear of problems in the sandbox, my suggestion is to
  1. create a new test user account. It might be that the existing test user account is associated with faulty data in the sandbox App Store Server. There is no support for clearing out the transactions associated with a user account - create a new test user account instead.

  2. download the StoreKit sample code <https://developer.apple.com/documentation/storekit/in-app_purchase/offering_completing_and_restoring_in-app_purchases?language=objc>. The sample offers targets for iOS, macOS and tvOS. It's written in both Swift and Cocoa.

2a. set the application bundle ID to that of your app.
2b. set the code signing to your developer ID
2c. set the in-app purchase identifiers in the productsID.plist for the target.
2d. Follow the sandbox test instructions as described <https://developer.apple.com/documentation/storekit/in-app_purchase/testing_at_all_stages_of_development_with_xcode_and_sandbox>

rich kubota - rkubota@apple.com
developer technical support CoreOS/Hardware/MFI
StoreKit Always Failing (Not on iOS 12) (Sandbox)
 
 
Q