In-App Purchase / On-Demand Resources

Using on-demand resources in conjuction with in-app purchases is understandable when resources are included with the application. But how do I add additional in-app purchases after the application is on the store? I'm not referring to the process of creating a new in-app purchase in iTunesConnect.


I'm trying to understand if i create a target for a new in-app purchase on the original app and upload the target to the app store if that data will be available for use as an in-app purchase. The WWDC videos indicate there two ways to host in-app purchases: on-demand resources and hosted content. I can't find any explanation

Answered by PBK in 313502022

Apple describes on demand resources here:

https://developer.apple.com/library/content/documentation/FileManagement/Conceptual/On_Demand_Resources_Guide/


These 'on demand resources' are, for all intents and purposes, "included" in the original app itself. I believe they must all be submitted with the app binary and approved at that time. They cannot be changed after submission. (The same is not true of hosted content.) While they are not downloaded with the app itself, the code that downlaods the on demand resources are included in the app and the.


Yes, you can have IAPs unlock the code that downloads on demand resources. The following is from the link above:

"The app offers in-app purchases that includes additional resources. The resources for purchased modules are requested by the app after it is launched. For example, a user purchases the SuperGeeky emoticon pack in a keyboard app. The app requests the pack after it finishes launching."

There are two parts to an IAP - making the purchase and delivering the goods.


In order for an app to make a purchase you must have 1) code in your app that will request a purchase of a particular productIdentifier and and entry in iTunes Connect that defines a price and various text charactistics for that particular productIdentifier. The app must then execute that code.


Once the purchase is made you then deliver the product to the app. This can be done by 1) including the product in the app itself and unlocking access to the product after the purchase or 2) by providing download access to the product only after the purchase has been made. To allow download of the product after purchase you need to place the product somewhere. You can do that on your server or you can use Apple to host the product. If you include the product in the app - that's it - you need to update the app to change the product. If you store the product on your server or let Apple host it you can change it at any time you want.

Thanks for your reply. What I'm trying to understand is if I create a target for a non-consumable iap that includes .json, .sks, and xcasset files, and upload that content to the app store, can I access that data via on-demand resources. There's nothing about the iap that requires a new app version and "Use Hosted Content" is off in iTunesConnect.


Here's some pseudocode describing how in-app purchase and on-demand resources might be used:

1. Get the SKProducts via productRequest(_ request, didReceife response:)

2. Use ODR to get .png thumbnails representing the iap from the xcassets file for display in my app's store

3. If the user makes a purchase, get the .json and .sks files using ODR

Accepted Answer

Apple describes on demand resources here:

https://developer.apple.com/library/content/documentation/FileManagement/Conceptual/On_Demand_Resources_Guide/


These 'on demand resources' are, for all intents and purposes, "included" in the original app itself. I believe they must all be submitted with the app binary and approved at that time. They cannot be changed after submission. (The same is not true of hosted content.) While they are not downloaded with the app itself, the code that downlaods the on demand resources are included in the app and the.


Yes, you can have IAPs unlock the code that downloads on demand resources. The following is from the link above:

"The app offers in-app purchases that includes additional resources. The resources for purchased modules are requested by the app after it is launched. For example, a user purchases the SuperGeeky emoticon pack in a keyboard app. The app requests the pack after it finishes launching."

Thanks so much for your help. I'll proceed along the line you mentioned of " IAPs unlock the code that downloads on demand resources". For anyone who might read this later, I believe it's essential that the Product ID in the target created with XCode match the Product ID for the in-app purchase in iTunesConnect.

In-App Purchase / On-Demand Resources
 
 
Q