In App Purchase “Gotchas”
In App Purchase is a terrific addition to the iPhone programmers box of tools. It’s a very versatile tool that developers can use to diversify ways of earning income from iPhone apps. Unfortunately, like app provisioning, when in-app purchase fails, it doesn’t give you a lot of details about why. This has led to a lot of misinformation floating around the net about various forms of voodoo developers need to perform to get their code working. Apple has a great tutorial about how to implement In App Purchase, so I won’t be going through the entire process, but I would like to highlight a few “gotchas” that seem to trip people up. Here we go.
- It probably won’t work right away. – This is the big one. It apparently takes up to 24 hours for a new product to propagate through Apple’s servers. Until that time your productRequest will not return a product. If you suspect this is the case, check the SKProductResponse object’s invalidProductIdentifiers array. If it contains a productID identical to the one in your iTunes Connect profile then you’re doing things right. You just need to wait a little longer and try again.
- You can debug with your usual provisioning profile. – Although all the information on Provisioning Profiles warns that you cannot enable In App Purchase in a profile that uses a wildcard in its name, this is not the case for development. You can successfully run your Store Kit code in Debug Configuration using any provisioning profile that works for your app.
- You must mark your product “Cleared for Sale” to test. – It seems like a step you shouldn’t take until your testing is done, but you must check the “Cleared for Sale” box in iTunes Connect to be able to test the product.
- You must run it on the device, not the simulator. – This one isn’t too hard to figure out, it actually gives you a clear error, but it’s good to know ahead of time. StoreKit code will not work in the simulator.
Hope you have a good experience implementing In App Purchase. Send me an email with further questions if things aren’t clear.
Cheers.