Getting IAP working for the AppStore basically involves the following major steps –
- Adding iTunes Connect record for a new app.
- Integrating Purchase logic in your code.
- Creating IAP products in iTunes Connect.
- Using Test Flight to test your IAP.
Setting up IAP in iTunes Connect
Before integrating IAP into your game, you have to create a record for your iOS application in iTunes Connect.
Make sure that you are enrolled to Apple Developer program for iOS applications. If not, you can enroll here –
2. Adding iTunes Connect record for your app
If you are already enrolled to an Apple Developer program, visit to the below link and login with your developer credentials – http://itunesconnect.apple.com
After clicking on My Apps, click on the + sign to add a new app.
3. Fill in your app details
Select a platform and Fill in the fields on the New App page to enter iTunes Connect properties for the app. After adding all info and creating, open your app from the dashboard by clicking on it. You should be able to see your app info like this –
NOTE: Make sure that the bundle ID that you are providing is same as of your iOS app for which you want to test IAP.
4. Add your IAP items
Add your IAP items to sdkbox_config.json
For example if you have the following item in your game
- “remove_ad” will remove the ad for player.
- “coin_package” will give player 5000 in game currency.
Your sdkbox_config.json will look like this –
5. Setup IAP products
Once the app information has been updated, you would be able to create IAP products now. Head over to the Features tab of your app inside iTunes Connect and click on the small plus button to add IAP products.
In the next window, select consumable/non-consumable depending on your IAP item and fill in all the fields asked for your In-app Purchase Summary, In-app Purchase Details and others and save it. After saving, your IAP item will be ready.
NOTE: It is not mandatory to submit your IAP products, if you just want to test them. You could have them in “Ready To Submit” state and need not to be published.
Integrate IAP with your code
Initialize iap when your app starts with following function –
Make purchase with following code
Note: the “remove_ads” is what’s in the sdkbox_config.json we edited earlier
At this point, you can test your IAP items in your iOS app.
You could also create a test ID by heading into the Test Flight tab of your app inside iTunes Connect and click on the small plus button to add internal testers like this –
Sign in with the Apple ID added to your internal testers list and you would be able to test your IAP.
In order to add Sandbox Testers for your iOS application, please go through the link
NOTE: You should test IAP on a real iOS device.
Suggested Reading :
You may also like to read –