How to verify if an iOS sandbox account is valid still? - ios

I'm having some issues with sandbox users. According to Apple's docs
Important: If you mistakenly use a sandbox tester account to sign in to a production environment, like iTunes, on your test device instead of your test environment, the sandbox account becomes invalid and can’t be used again. If this happens, create a new sandbox tester account with a new email address.
In my case I haven't tried to login to the production environment with these accounts, but am still getting the invalidated somehow. It seems they will be good for a day or two, and for the first couple purchases and then stop working.
I'm getting back SKErrorDomain Code: 0 NSLocalizedDescription: Cannot connect to iTunes Storemost times when I try to purchase.
Most recently I even got "You are not authorized to make purchases of this InApp Purchase in Sandbox at this time. [Environment: Sandbox]"
I'm very flustered by these errors because it seems that it will work fine and then intermittently stop working. Has anyone found a way to successfully verify if an account is invalid, or found a way to get past these issues?

Each time I run into this problem, these steps typically clear it:
Make sure phone is signed out of all services (iCloud, App Store, everything)
Restart the phone.
Remove the app from phone and re-install via Xcode
When the app prompts for credentials during in-app purchase, enter sandbox credentials.
There is the very off chance that the sandbox account must accept some new terms from Apple. Log-into developer.apple.com and make sure you don't have any lingering alerts for that account.
Best of luck!

Related

iOS sandbox test user account not working properly

I'm trying to test my app's in-app purchases but when I try to log in as my sandbox tester it tries to send me to the settings screen to sign in there. however as I understand it, wouldn't that invalidate the tester.
Steps in order as I did them:
1: Create sandbox tester account on iTunes connect
2: sign out of itunes and app store as well as iCloud
3: opened the app and tried to purchase something. was prompted, telling me to sign into an account.
4: Signed in using the test users credentials and still got redirected to the settings screen. What am I doing wrong?
According to some people on the apple developer forums, regarding this particular issue, of course, you need only to verify the account and it seems to have done the trick for me.

Unexpected login prompt for test user in iOS sandbox

I am testing in-app purchase and restoration. Testing was going fine until I tried to switch test users.
I mistakenly tried to sign in via Settings ("iTunes & App Store"), where I signed out as Test User 1 and started to sign in as Test User 2. When the App Store gave me "This Apple ID has not yet been used in the iTunes Store, etc." and prompted for my credit card information, I realized my mistake and cancelled the sign-in.
But now every time I run my app via XCode, it prompts me to "Sign In to iTunes Store" as Test User 1. I cancel it and then everything proceeds normally. But I would like to get rid of this weird behavior.
I have tried signing in. That doesn't stop it. Then I tried going into Settings ("iTunes & App Store") and signing out. That also doesn't stop it. Also tried rebooting phone and then a hard reset.
This problem went away overnight. It may have beeen a caching issue with the sandbox and/or App Store.

Testing In-App Purchase on iPhone

I have setup my app to use In-App Purchases. All the necessary steps have been done and everything works except for one thing, the final step for completing the purchase transaction i.e. SKPaymentTransactionState always completes with Failed every time.
So I did some research and found another post that said not to test this in the simulator and do it on a physical device as it seems there is a limitation placed on making purchases in the simulator by Apple on purpose.
So I went back to try to run this on my physical iPhone instead. The problem I'm having now is that my physical iPhone is linked to my active iTunes account. When I try to make a purchase on it, the User ID is already defaulting to my active ID and it only asks for my password.
So my question is (1) How do I force the phone to ask for me to enter a new User ID and Password so that I can use the Sandbox User I created in iTunes Connect? (2) I am a little nervous about even entering a secondary iTunes credentials, can anyone validate what the behavior is like? I do not want my active iTunes account to have any issues, it is possible to run both my active iTunes account and the sandbox user on my physical device with no issues?
Log out of iTunes on the phone via Settings, but wait for the app to prompt you to log in before entering your sandbox account credentials. NOTE that I'm referring to iTunes, not iCloud. It gets more interesting if you need to do that.
When you're done testing, log out again via Settings but differently than before, go ahead and re-log in via Settings to your "regular" Apple ID to return to production use.
You can't run them "simultaneously" as such but you can use your regular device to sandbox test without problems.

In-App-Purchase behaviour using a real Apple ID

Clarification
I know, there are tons of questions about In-App-Purchases, some of them also about dealing with real Apple IDs, but I found none with a really precise answer about the exact behaviour / errors you get, doing so.
The actual question
I have an app with IAPs, whenever I try to log in using my real Apple ID, and the app is asking for products / prices or trying to buy something, I get the following error popups.
Entering the valid password
Entering a wrong password
Already logged in when starting the app (in Settings => iTunes & App Store)
Can someone please confirm (or refute) this to be the expected behaviour?
To summarize the question(s)
Is it correct, that real Apple IDs only work in distribution signed apps (for/from the AppStore) and won't work in development signed apps?
Sandbox Accounts work in a Sandbox Environment no matter how the app was signed?
Is it correct, that real Apple IDs only work in distribution signed
apps (for/from the AppStore) and won't work in development signed
apps?
Yes. You can't use real apple IDs' in your sandbox environment.
Sandbox Accounts work in a Sandbox Environment no matter how the app
was signed?
Test users created under your account will work with the development build. It won't work with production builds which are downloaded from Appstore.
P.S. You can use a dummy email to create sandbox testers (not sure whether it still works :) )
https://developer.apple.com/library/ios/documentation/LanguagesUtilities/Conceptual/iTunesConnect_Guide/Chapters/SettingUpUserAccounts.html#//apple_ref/doc/uid/TP40011225-CH25-SW10
When I implemented iAP last month I got exactly the same experience. It all worked perfectly once the app was signed and released on AppStore so you should be safe.
The sandbox account works only in a sandbox environment and will not work if you download the app from the AppStore.

Can not log into sandbox by test account on iOS

I am implementing in app purchases for my app. I am logged out from AppStore, created some test accounts, have not verify it by e-mail.
And every time I tried to log in into sandbox app-purchase I got an transaction error. Btw product info restored correctly.
Looking deeply I notice that after any attempt to log in, my AppStore account setting in device filled with the info from this test account! So I think it tries to log in into real AppStore instead of sandbox.
What am I doing wrong? Why my test accounts tries to login into the real AppStore and how to fix it?
To know if you're in sandbox environment or not, you can have a look at the purchase popup. If you can read "[Sandbox environment]" at the bottom, then it means you're using the sandbox. Otherwise, you're using the real Appstore (But I'm pretty sure it's not the case since this is automatically chosen by the device).
Anyway, it seems that Apple Sansbox environment is experiencing some problems today.
For example, I have an app that was dealing correctly with inapp purchase yesterday. Today, only retrieving SKProducts was ok.
I recommend you to be patient until the problem is fixed by Apple.

Resources