I am working on adding In-App purchases to my app.
I am able to receive the productsRequest:didReceiveResponse
method, and receive the array of products
Check if you are signed into your personal itunes account in the appstore. If you are you will receive this message. Even if you are signed into your sandbox account in the app. So, to resolve this issue sign out of your personal account in the app store and then try to purchase your in-app item and then use your sandbox account. This resolved my issue.
Make sure your BundleIDs match. That was my problem.
The In-App Purchase FAQ has this information:
Cannot connect to iTunes Store
The "Cannot connect to iTunes Store" issue may be due to one or more of the following reasons:
- The sandbox may be unreachable.
- Your app does not have a bundle version (CFBundleVersion). See Setting the Version Number and Build String for more information.
- Your app is running in the Simulator, which does not support in-app purchase.
- You are attempting to purchase a product that is unavailable for sale. See Query the App Store for product information before presenting your app’s store UI for more information.
In my case, the error occurred because I was using the simulator.
Even in the In-App Purchase Programming Guide says to use the development iOS device has a suggested testing step.
I have tried all what I can to deal with this issue.
Real device not Simulator.
New registered Sandbox test account (not fill the extra info to make it a formal Apple ID)
Logout whatever accounts related.(iCould, App Store, maybe other app's sandbox testing account)
Fill all the tax and Agreements in itunesconnect website
Even restore to factory settings LOL ...
always return SKErrorDomain Code=0
“Cannot connect to iTunes Store”
...
My case's solution is finally come tome after 3 days' struggle:
And finally I find the key. Try with another device to test the iAP if your device's iOS is iOS13.4.x!!!And I upgrade this ”broken“ device's OS version to iOS14.0.1, iAP works like a charm.
This error (i.e. "Error! Cannot connect to iTunes Store") can occur if you do a sandboxed In App purchase but are signed in using your normal Apple account.
I find it helps avoid any confusion if I sign out of my Apple account before doing any In App purchases. Then in the "Sign In" dialog choose the "Use Existing Apple ID" option and enter your Test User details.
Just remember this will be set in your Settings so you will need to sign out after you've finished In App purchases.
Also, using a different Apple ID resets various iTunes-related settings such as iTunes Match.
I thought it worth mentioning that DonnaLea's solution of only logging in when prompted for payment also worked for the same issue with Unity and Prime31's StoreKit plugin. Attempting to log in via the same settings menu you use to log out will prompt for all manner of billing\address details which seems to permanently "break" that test account.