Note: I haven’t actually had any of my apps approved in the AppStore that has In-App purchasing built in but I do have a couple in development. I do have 60+ apps in the appstore though.
Firstly, I’m the type of person in the development world who likes to jump into the water before dipping my toe in. It’s a crude method of self training but it’s served me well. I freely admit I don’t have formal training in the theories of memory management or agile development. I just like to code and see my work out there. If I get trashed for it, then by all means, call me out and educate me… I may learn something new which is my goal.
In-App purchasing sucks to develop for. I thought Push notifications was crappy but then I wanted to throw this feature into an app and boy oh boy does Apple suck at getting logical tutorials out there for the layperson (lay-developer?) like myself.
First, ground rules to getting In-App purchasing to work, at least in a test world.
-No jailbreak on your test device.
I know, I know…I hate that too but it’s 100% necessary. I like to have sbSettings and tether working for me too but if you want to have a working test device for in-app purchasing, suck it up, buttercup.
-Full bundle id for your app.
None of that mamby-pamby wildcard bundles like com.company.* Needs to be com.company.super-hella-sweet-app-yo
-Your product IDs in iTunes Connect In-App area can be the full bundle id or not.
I see a bunch of tutorials saying “you HAVE to have the full bundle id, com.company.super-hella-sweet-app-yo.product1″ but i have found that it’s up to you. It can be anything. Short, long, medium. It’s hooked to your app’s bundle Id anyways so it doesn’t matter (at least in my testing).
-Log out of your iTunes on your phone.
Settings > Store > scroll to the bottom > Touch your UserID and then hit “Sign Out”
-Find a good wrapper for StoreKit.
I found MKStoreKit.
-Think ahead.
When you are writing something that will use In-App purchasing, you REALLY need to have a good plan on how you want to implement. How to restore purchases if they have already bought something but reinstalled the app. How to disable something if they haven’t purchased, NSDefaults for example.
Now the first thing I wanted to do was to create a view that would show purchasable items. Doing this does two things. First, shows a list of items a person can buy and two, validate a purchase is available from the technical side. If you show a view of products you get from the store and it’s blank, hard coding the buy won’t work either so there’s really no sense in trying it.
Plus, it allows for you to administrate the available products from iTunes connect rather than doing a version update with different hard coded products. And its REALLY hacky… coming from me, that’s saying a lot.
To follow a nice tutorial based on MKStorekit, go here. He gives you all the basics walk-throughs that I’m too lazy to give you.