Search code examples
iosin-app-purchasestorekit

One in-app product with multiple variations


Can I create one in-app product for, say, some music, and then vary the exact track based on a database key?

So the user would buy a music product but the app keeps track of the exact data which comprises their instance?


Solution

  • As @Paulw11 said in his comment above, you can setup a consumable product ID that offers one or more "credits". Using the concept of credits is the only way you can dynamically allocate products to purchases without adding a product ID for each song in iTunes Connect.

    Consumable products can be purchased multiple times, so allocate credit or direct the user to select the song once they buy the product. Be sure to call finishTransaction to "consume" the purchase, otherwise the transaction will remain in the queue and additional purchases will be blocked.

    Be warned though, consumables are not restorable; if the user deletes and re-installs the app all their songs will be lost. One way to deal with this is to keep a server-side registry of songs a user has purchased, which means you will need user management and authentication etc.

    Here's another stack question relates to yours.