Where to store downloadable in-app purchases?

My app has downloadable in-app purchases. When the content is loaded, I save it right now in the document directory. But I know that Apple is a nitpick and will probably reject my application, because the content that can be restored should not be stored in the document directory, which means it will be saved in icloud.

I was thinking about using temp or cache directories, but they can be emptied anytime iOS needs space.

Where can you save it?

+3


source to share


3 answers


The directory Documents

can only be used for user data that cannot be downloaded (including potential databases that contain user-selected options, etc.), so you are correct, you will probably be rejected if you save downloadable content there.

The way I did it was to store the loaded data in Cache

(which, as you say, can be flushed at any time when the space is low) and store a small chunk of data in Documents

that says the content should be in Cache

. When it Documents

says that the data should be there, and it isn't, I will notify the user that the content was automatically deleted by iOS due to space issues and prompt the user to download it again.



Thus, if the user has not been using the content for a while, he can reuse the space on his device for other purposes and can still download the content as he pleases. Just like I want the app to work if I were a user :)

EDIT: You can put them in Library

if you need them to be permanent at all times, but remember to mark them as not backed up to iCloud or you will most likely get the same rejection.

+6


source


I also read the docs folder for user generated content and I am encouraged to use the cache folder, even though your data can be deleted if needed. I also read that using flag folders without backup might be the choice when setting up ios 5.1 and above.

See iOS 5.0.1: How to check that a folder is marked as "Do not back up". for iCloud?



Adding "Don't make backup"; folder hierarchy attribute in iOS 5.0.1

0


source


Documentation here https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/StoreKitGuide/Chapters/DeliverProduct.html#//apple_ref/doc/uid/TP40008267-CH5-SW5

says the folder Documents

is the place to move the content if you want it to persist.

On iOS, your app can manage uploaded files. Files are saved for you using the Store Kit framework in the Caches directory with the backup flag disabled. Once the download is complete, your application is responsible for moving to the appropriate location. For content that can be deleted if the device runs out of disk space (and then re-downloaded by your app), leave the files in the Caches directory. If not, move the files to the Documents folder and check the box to exclude them from custom backups.

0


source







All Articles