Arvind
Arvind

Reputation: 493

How to buy additional in-app items for an app from apps store?

Let me explain my question with an example scenario:

I'm creating an app like paint with a few basic features like draw straight line, choose line color from list, etc...

There are some other features which are available to the user only when they pay for it, like:

User can buy the tools they wish.

I need to know how this can be done, i. e., how the in-app purchase from apps store is possible.

Upvotes: 0

Views: 232

Answers (1)

RabinDev
RabinDev

Reputation: 658

Apple allows you to have different kinds of in-app purchase for your app - consumable purchases, that the user uses, and eventually the user uses them and need to re-buy the same feature - like life points in a game, or license to do something x number of times. Another type is non-consumable - an item that the user buys and can use without limit forever - they bought it, so they own it - like using a tool in a paint application. There is also a subscription and others, but these are what you should be looking at.

NOTE: for in-app purchase to work, you MUST have an application bundle name that is unique and specific, that is not "www.ArvindSoftware.*" but "www.ArvindSoftware.MyappName". You must also use this app id in specific provisioning profiles you will create for this app in iTunes connect - an ad hoc profile and distibution profile.

To add an in-app purchase you need to add in-app purchase items in your application in iTunes connect website. For each product you can choose the name, description in many languages and price tier. Give each product an id that is unique and readable, something like "www.myCompanyName.myappname.myproductIDName", for example "www.ArvindSoftware.GreatPictureEditor.UserCanCropAnArea". Once you have set up the available items in the iTunes connect website, you write the client side for it.

Search for MKStoreManager and MKStoreObserver, they are two classes that wrap up the purchase process from the app store, and are for free. You must include the StoreKit framework into your project. Basically, these classes manage a request to the app store to purchase product with a given "ProductID". The storeKit framework does the rest for you - chck if the product exists, and ask the user to buy it, enter user & password etc.. Once the transaction is complete, you get a notification that product "ProductID" was purchased and the quantity that was purchased (for non-consumable, a user may purchase only once, if the user has already purchased, they do not need to pay again)

There is also a way to restore previously purchased items for the specific user, so that a newly installed app will know if any of it's in-app purchasable items were already bought by the current user.

To test the purchase you can create a test user in iTunes connect, and log out of the real user account in your iPhone/iThing settings>store section. You then test the app, and when you ask to purchase the in-app, you enter the test user's username and password. The purchase if marked as [Sandbox environment], so the purchase is a test purchase.

Read more online.

Upvotes: 1

Related Questions