Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

(iOS + StoreKit) Can I detect when I'm in the sandbox?

I've got in-app purchases working just fine, and I'm going the server validation route. The server needs to know whether I'm in the sandbox or not, so for now I'm just sending it a "&sandbox=1" parameter. Of course when the full version of the app is out I won't be sending this parameter.

I'd rather not have this hardcoded in my app, as that will make testing difficult in the future, and it's one more (big) thing to remember to change before submitting builds to Apple.

Is there a way I can ask StoreKit if I am in the sandbox so I can then determine whether or not I need to send this parameter to my server? Alternatively, is there any other best practice for handling server validation?

Thinking about this more, should I just have the server always check the live system first, then the sandbox? If apple IDs are segregated between the live and sandbox systems then it wouldn't do any harm would it?

Thanks.

like image 897
DOOManiac Avatar asked Mar 13 '12 01:03

DOOManiac


People also ask

What is Sandbox testing in IOS?

Overview. Use the Apple sandbox environment to test your implementation of in-app purchases that use the StoreKit framework on devices with real product information from App Store Connect. Your development-signed app uses the sandbox environment when you sign in to the App Store using a Sandbox Apple ID.

What is Sandbox Environment IOS?

A sandbox is a set of fine-grained controls that limit the app's access to files, preferences, network resources, hardware, and so on. As part of the sandboxing process, the system installs each app in its own sandbox directory, which acts as the home for the app and its data.

Does Apple have sandbox?

The Apple sandbox environment lets you test in-app purchases on devices using product information set up in App Store Connect.

Is TestFlight a sandbox?

TestFlight users don't require a sandbox account, but they will test against an automatically created sandbox account. This means it's no longer necessary to create test accounts in iTunes Connect.


1 Answers

After a bit of digging I found this from Apple's Technical Note TN2259:

How do I verify my receipt (iOS)?

Always verify your receipt first with the production URL; proceed to verify with the sandbox URL if you receive a 21007 status code. Following this approach ensures that you do not have to switch between URLs while your application is being tested or reviewed in the sandbox or is live in the App Store.

So it looks like I should axe the &sandbox parameter completely and just do that. I really had to dig for this answer so I'm posting it here in hopes that someone else runs across it!

like image 198
DOOManiac Avatar answered Sep 24 '22 02:09

DOOManiac