I am having problems testing my in-app purchases. I get back valid product identifiers, but upon purchase I receive the dreaded \"Cannot connect to iTunes Store\". Interesti
I fixed mine! If you are getting Error Domain=SKErrorDomain Code=2 "Cannot connect to iTunes Store"
error, make sure you insert SKPaymentQueue.default().finishTransaction(transaction)
. It worked for me after I added SKPaymentQueue.default().finishTransaction(trans)
in the following:
func paymentQueue(_ queue: SKPaymentQueue, updatedTransactions transactions: [SKPaymentTransaction]) {
for trans in transactions{
if trans.transactionState == .purchased {
print("Successful.")
SKPaymentQueue.default().finishTransaction(trans)
} else if trans.transactionState == .failed {
print("failed!")
print(trans.error)
SKPaymentQueue.default().finishTransaction(trans)
}
}
Found in Apple developer website, here
For newcomers, make sure your in-app purchasing product's status is Ready to Submit
, with no "missing metadata". In my case, what was missing was the localization of the subscription's group.
Make sure you have signed out of any production iTunes accounts on the device.
I was getting this error on my test phone which was logged in with my actual iTunes account. You cannot test apps using your production iTunes account, hence the error. I just wish Apple provided a better error so as to avoid this guesswork...
Make sure the system status is ready https://www.apple.com/support/systemstatus/
I have an Iphone, Restart it worked for me
I had to go to Settings > iTunes & App Stores, then scroll to the bottom to the "Sandbox Account" field and Sign out from there. Now it is working!!!
This problem remains persistent in 2016. Incredible. Here was my solution:
Add a build number. Target > General > Identities > Build.