SwiftyStoreKit
SwiftyStoreKit copied to clipboard
Multiple occurrences of IAP not passing and restore returning: Cannot connect to iTunes Store
Platform
- [x] iOS
- [ ] macOS
- [ ] tvOS
In app purchase type
- [ ] Consumable
- [x] Non-consumable
- [ ] Auto-Renewable Subscription
- [ ] Non-Renewing Subscription
Environment
- [ ] Sandbox
- [x] Production
Version
running on swift-2.3
branch
Related issues
#140 but contrary to that person I cannot reproduce myself this error. But it happens to about 25% of my transactions which is a big deal at the moment. (Last week on 50 transactions I got about 9 of them who got that error).
Report
Issue summary
Multiple customers are emailing us about not being able to purchase our IAP for our PRO version.
One said "i buyed the pro version, but the ads still on. And App says nothing to restore."
Basically, we have a buy pro version in the app's preferences. When they press on it a call to SwiftyStoreKit.purchaseProduct is done.
When he tries to restore, results.restoreFailedProducts = [(Error Domain=SKErrorDomain Code=2 "Cannot connect to iTunes Store" UserInfo={NSLocalizedDescription=Cannot connect to iTunes Store}, nil)]
What did you expect to happen
Transactions should pass and when they do they should and result in errors they should at least be restorable if the initial transaction went okay.
What happened instead
Purchase never seems to pass. Restore returns a cannot connect to itunes store error. Leaving the customer without any way of getting the product.
Just for more information, I added both my purchase and restore methods here. Feel free to ask for more details. Please don't mind the debug calls.
static func purchasePro() {
SwiftyStoreKit.purchaseProduct(ProProductIdentifier) { result in
switch result {
case .Success(let productId):
self.hasPurchasedPro()
// reloading UI to get rid of ads
self.reloadAdUI()
if Consts.DebugPurchases {
self.notificationHandler.displayAlert("Purchase Success", message: "\(productId)", type: .Success)
} else {
// logging event
LoggingHandler.reportEvent("PurchaseProSuccess", customData: ["productId": "\(productId)"])
}
case .Error(let error):
if Consts.DebugPurchases {
self.notificationHandler.displayAlert("Purchase Failed", message: "\(error)", type: .Danger)
} else {
// logging event
LoggingHandler.reportEvent("PurchaseProFailed", customData: ["error": "\(error)"])
}
}
}
}
static func restorePurchase(silenced: Bool) {
// trying to restore something
SwiftyStoreKit.restorePurchases() { results in
if results.restoreFailedProducts.count > 0 {
// if debug, display response
if Consts.DebugPurchases {
self.notificationHandler.displayAlert("Restore Failed", message: "\(results.restoreFailedProducts)", type: .Danger)
} else {
// silence this notification and logging
if !silenced {
// contact support if this seems wrong
self.notificationHandler.displayAlert("restore_error".localized(), message: "nothing_to_restore_is_it_wrong".localized(), type: .Danger)
// logging event
LoggingHandler.reportEvent("RestoreFailed", customData: ["restoreFailedProducts": "\(results.restoreFailedProducts)"])
}
}
} else if results.restoredProductIds.count > 0 {
// mark user as pro and reload ui
self.hasPurchasedPro()
self.reloadAdUI()
// if debug, display response
if Consts.DebugPurchases {
self.notificationHandler.displayAlert("Restore Success", message: "\(results.restoredProductIds)", type: .Success)
} else {
// logging event
LoggingHandler.reportEvent("RestoreSuccess", customData: ["restoredProductIds": "\(results.restoredProductIds)"])
}
} else {
// silence this notification
if !silenced {
self.notificationHandler.displayAlert("restore_error".localized(), message: "nothing_to_restore".localized(), type: .Danger)
}
}
}
}
same problem
@tbergeron You mentioned that you're running on the swift2.3
branch.
If that is definitely the case, I would recommend moving to the latest version (Swift 3).
I have one app running in production with SwiftyStoreKit v0.8.3. From my analytics dashboard I can see that some restore purchases calls are either failing or returning no purchases. Will need to investigate more and add some error information to my analytics.
Unfortunately I won't be able to look at this over the next two weeks (on leave with no laptop).
I have now upgraded my app to Swift 3 and pushed the update. It is now live so I'll be able to see if the latest update improves my issues.
It seems to be better. The only errors that are reporting have the same message:
SKError(_nsError: Error Domain=com.apple.LocalAuthentication Code=-2 "Canceled by user." UserInfo={NSLocalizedDescription=Canceled by user.})
But I don't see the cannot connect to itunes store message anymore so far. So far so good!
I guess that's just curious people tapping the button and cancelling. I'll contact the users who reported this issue to ask them if they can now purchase the app. I'll update this thread once they replied.
Thanks for the help!
Unfortunately this is persisting. I've got people from Australia, Canada, USA & Brazil who cannot purchase the app. All of them have the same error message in a different language. I'll try to bring more information to this issue soon. Thanks
I tagged this as a bug, however we need more information to understand why it is failing.
I recently discovered that Apple recommends using the receipt to find purchased products, rather than restoring purchases directly.
See my answer here #207.
Maybe you could try to implement this with receipt verification instead?
We are experiencing the same issue mentioned by @tbergeron. For over a month now a large number of purchases are failing in our app. All return a variation on this error, with code=0 or code=2:
SKError(_nsError: Error Domain=SKErrorDomain Code=0 "Cannot connect to iTunes Store"
We have also upgraded swift and released a new version earlier today. Only to discover that the same problem is still present.
I can confirm same error as @Randam: state: failed, date: nil Error Domain=SKErrorDomain Code=0 "Cannot connect to iTunes Store" UserInfo={NSLocalizedDescription=Cannot connect to iTunes Store}
Looked back at my analytics, this is still happening for me too on the latest versions of iOS/SwiftyStoreKit. It's not a high percentage but it is definitively still happening. Every users I asked told me they didn't have any connectivity problems or any problems with the app store meaning they should be able to go through the purchase but some aren't able to for some unknown reasons.
Apologies everyone, I know this is an ongoing issue but I'm not sure how to best diagnose and address this. Suggestions welcome.
@bizz84 any updates , i found this in apple forms
"After numerous reports of this issue to DTS, I managed to replicate the problem myself. So far as I can tell, the issue occurs only with new test user accounts. If you go to your iTunesConnect account and enter "User and Roles" -> "Sandbox Testers" page, you will see a list of your sandbox test accounts. If you create a new test user account, notice that there is a check mark in the rightmost column, "Apple Pay". Using such a test account appears to trigger this problem. Developers who have older test user accounts (defined prior to June 13. 2016) won't see this problem.
I've submitted a bug report on this matter, but what I need is a TestFlight submission along with a developer test user account. I think I have such a build coming and will forward the issue to iTunes Production Support for investigation by tomorrow. My suspicion is that this will not affect application submissions - App Reivew tests with mostly established production accounts. This problem will get a lot more (and quicker attention) if it happens in the production environment."
Just to follow up on my original report: we eventually had to 'fix' this issue by leaving out the SwiftyStoreKit alltogether. A fresh plain StoreKit implementation did the trick, and it wasn't very hard (just 1 day of refactoring).
Has any progress been made on this?
I am having the exact same problem, and it happens on my own iPhone X...so hilarious. I had report from my user that they were able to purchase the IAP, but myself can't.
Also this problem is seen on both restore and fresh purchase. I am using Swift-4 BTW. Will monitor this thread.
Interestingly, this issue went away after I rebooted my iPhone...
We also faced with this problem
@tbergeron Have you found any solution? We have a similar issue but in our case about 70%-80% of payments fail (error code 2 or code 0). Some may intentionally click cancel button while purchasing but for me the numbers are much too big to assume that this is normal behavior.
Anything on this? @alexanderkhitev @tbergeron @Wilsonilo
Anything on this? @alexanderkhitev @tbergeron @Wilsonilo
hey @gbesler ! no, I don't have any updates now.