Now that 20 Saxophone Tricks of the Trade is waiting for review, I will add a In App Purchase feature on some of my big apps and make a small version (or free in some cases) of them with limited access and let the user decide if they want to add more features to them by purchasing “modules” within the app.
My current full version is ready for sale on the App Store, and it contains two volumes in one app :
I want to make a Volume 1 (only) version and let the use decide if they want to purchase Vol. 2 within the app
At the moment this is what apple have for a tutorial : https://developer.apple.com/library/ios/technotes/tn2259/_index.html
Here’s my own version on how I did it:
Setting it up
- I copied the xcode project folder of the full version of the app to another folder.
Then opened the project with xcode and rename the box Identity and Type and accepted the changes offered by xcode
- Next I went to the Apple Developer IOS Provisioning website and created a new Identifier for this new version of the app.
For the Bundle ID I used and Explicit App Id com.mdecks.xxxxx (xxxx being the name I used for the Identity and Type, it doesn’t have to be the same but it is easier this way)
Make sure the In App purchase option is checked
- Then created two provisioning profiles for that ID. One Development and one Distribution. Download them and double click the files to add them to xcode
- Now go to the iTunes Connect website and create the record for the app linking it with the ID I created on the developer site.
There you can fill as much info as possible. Description, Icon, Screen shots (if you have them already, etc)
- Then go to the In-App Purchases tab for that app and create a new one. In my case is a non-consumable one since once the user’s paid for it it will be available without expiring.
There you will have to choose a reference name, and ID, choose the price and add a Language for every language supported by the app (which in my case is two English and Spanish)
Also you have to select Clear for Sale: YES. You can upload a screen shot later on, before submitting the app
- In order to test the In-app purchases in XCode you need to create a sandbox tester user which is done also in iTunes Connect. You can access this on the main page where it says Users and Roles. I created a couple of them, you can use any emails and names, they do not have to be real ones, just remember the email and password
- Ok. Back in XCode go to the Build Settings and change the provisioning profile to the one you’ve created for development. If you did it right then in the General tab the Identity shouldn’t show any problems.
- Enable In-App Purchase in the Capabilities tab
- There’s an amazing tutorial by Ray Wenderlich with a sample code download. I suggest you read it since is very well put together.
- In Ray’s solution there’s a class that takes care of all the In-App purchase methods and events. Then you create a subclass of that one and tweak it for your products and needs, and a TableViewController subclass that will show all the In-App purchases IDs you’ve created for your app, letting the user buy any of them from that table. There’s also a restore button to retrieve the in-app purchase IDs that have been purchased by the current user (very useful when the user has deleted the app and reinstalled it)
- Note 1: One of the things I was confused about was the productIdentifiers. When I tried the first time I got an in-app purchase invalid product. I finally got it working by just using the ID for each in-App purchase as shown in iTunes, without any prefixes (just the productID that’s it !)
- Note 2: The simulator in XCode did retrieve the list of products without a problem, but to try the entire purchase process you must run your app in a real device, (previously signing out of the App Store) and then at the moment of purchasing use one of your SandBox Tester Users (and it will show as such in the alert dialogue on your device)
That’s all. Now the app is waiting for review on the app store
I also added some in-app purchases to the guitar app which is also waiting for review on the app store:
And I am working on adding 4 modules of in-app purchases to the free version of my piano app: