❮ zur Übersicht

Testing Apps with In App Purchases in Simulator

  • Autor: David Linsin
  • Datum: 30.08.2010

If you add a store to your app and use In App Purchases to collect your payments, there are a couple of limitations your have to live with. One of those limitations is not being able to fully test your App in the iPhone Simulator:

Store Kit does not operate in iPhone Simulator. When running your application in iPhone Simulator, Store Kit logs a warning if your application attempts to retrieve the payment queue. Testing the store must be done on actual devices.

Although, there is not way to test Store Kit itself, you can still test the parts of your App that use and build on the information retrieved from Store Kit. You can use a preprocessor conditional inclusion to determine, whether you are running on the simulator and then “mock” the Store Kit calls or don’t execute them at all.

#if TARGET_IPHONE_SIMULATOR

// mock product description     

#else

SKProductsRequest *productRequest = 
[[SKProductsRequest alloc] initWithProductIdentifiers:productIds];
productRequest.delegate = self;
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
[productRequest start];

#endif

Keep in mind: this might not work for your App, however, it did work for our Apps and it’s better than not testing your code at all. The optimal solution would definitely be to connect to the In App Purchase Sandbox environment from the Simulator.

Tags: apple iphone testing