[iOS SDK] How to test In-App purchases in your iOS device.

One difficult thing to implement in iOS SDK is an App offering In-App Purchases (from now on, IAPs). There are plenty of tasks to be done in iTunes Connect (Tax, Banking and Contracts, Manage Test Users, Manage Apps, Create App IDs, certificates, provisioning profiles, …), then tasks to be done in Xcode, and also a few more in the iOS device (look well, I said iOS device! and not SIMULATOR!).

The first thing you have to know is that In-App Purchases cannot be tested on the iOS Simulator. If you were trying to do that, or were planning to try, spend your time in something better.

But even in the iOS device, it is not trivial to find the way to test if our IAP implementation is working fine. Here are the steps for doing it. Following them carefully will for sure save you time and headaches 🙂

Prerequisites:

  • iOS App created in iTunes connect, all fields filled and screenshots uploaded. Must have “Ready to upload binary” status.
  • At least one in app purchase created for the iOS App, with its SKU and Bundle ID. I suggest you this tutorial for this point and the previous one.
  • An email account that has no AppleID associated. Immediate access to its inbox.
  • An Xcode project with IAPs implemented. I suggest you this tutorial

Steps:

1.- In iTunes connect, go to Manage Users and create a Test User with the email account mentioned previously. Fill in the rest of the fields (name, secret questions, date of birth, …). Specify a password and take note of it, we’ll need it later.

2.- Get into the mentioned email’s inbox. There should be a mail from Apple with an activation link. Click it to activate the AppleID, note that the email from Apple could be on the Spam folder.

3.- Once the user is created, in your iPhone/iPad and go to Settings > iTunes Store and App Store > Apple ID (on top). Tap on it and select Disconnect in order to logout your AppleID from the iOS device.

4.- Run your iOS App, navigate to your purchase menu, and click on the “Buy” or “Purchase” button. It will ask you for your AppleID, select Use an existing Apple ID and fill in the email and password of the Test User activated in steps 1/2. A message asking you to purchase the item in [Environment: sandbox] will appear. You can buy the item or cancel the transaction and test what happens on each case. After the first purchase, you can try to uninstall the App, reinstall, and purchase the item again to see if your restoration works correctly.  That’s all

Steps 3 and 4 are specially important because this is the only way to make the IAP test work. If you try, for instance, to log in the iPad with the AppleID and password of the Test User, it will come with “This AppleID is not activated in the App Store” and ask you for data / credit card. Also, if you try the step 4 with another Apple ID logged in (not the Test User), it will return a “Can’t connect to iTunes Store” message and IAP won’t work.

 

Hope it helps! Let me know any issues 🙂

Advertisements

One thought on “[iOS SDK] How to test In-App purchases in your iOS device.

  1. Pingback: Giuseppe Ventimiglia

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s