IOS - In-app purchase downloadable media storage guidelines - ios

I have an app which has in app purchase downloadable videos. The first time I submitted to the app store it was rejected because I was writing it to <Application_Home>/Documents directory. The rejected reason stated that
In particular, we found that on launch and/or content download, your
app stores 20MB.
I read the guideline and it told me that
Data that can be downloaded again or regenerated should be stored in
the <Application_Home>/Library/Caches directory. Examples of files you
should put in the Caches directory include database cache files and
downloadable content, such as that used by magazine, newspaper, and
map applications.
I checked the simulator's cache directory and found that there is a default folder within the Caches folder with the name of the Bundle Id of the app. So I changed it to the following path
<Application_Home>/Library/Caches/<Bundle ID>/
Ran this in the sim and seems fine. However, when I uploaded it, it was rejected. The problem seems to come from writing the data.
Question: Is there something wrong with this directory? Should I just store it in the Caches root folder?
Thanks.

Related

How do you persist image references across app updates on iOS devices

I have developed a Flutter app that captures images using the camera and I store references to the image files using Shared Preferences.
When I upgrade the iOS app, the Shared Preference filename persists as expected, but the image no longer displays on the iOS device (and no longer seems to exist) File(_imageFileRef).existsSync() is false
For example, on iPhone, the image file is saved as
/private/var/mobile/Containers/Data/Application/580A9879-23CD-413D-A785-DB910673DF74/tmp/some_guid_image_name.jpg
When the app is upgraded, this file no longer seems to exist.
Where should I be saving the image files to in iOS so that they persist across upgrades?
The functionality works perfectly on Android devices.
Having received no answers, I delved a bit deeper and discovered that...
...the tmp directory in which the images are being written is for temporary files that do not need to persist between launches of your app. Your app should remove files from this directory when they are no longer needed; however, the system may purge this directory when your app is not running. The contents of this directory are not backed up by iTunes or iCloud.
So in order for the data to persist over app updates, I need to be writing to the Documents directory
Info obtained from here

iOS: Include the resource(audio) files into the application folder of the app rather than adding into the bundle

Currently my resource(audio) files is included in the bundle. Due to this user is unable to delete the unwanted audio files to save the disk space on his phone. Please let me know how can I directly include the audio files into the Applications folder of app while submitting the build to AppStore and not in the bundle. Thereby user can delete the files which are not of his interest and re-download from the cloud backup hosted on S3 if needed.
The only way to accomplish this is to NOT have the audio files included in the initial app install.
Instead, your app could download the audio files from a hosting service... either download them all on first launch, or download each file as-needed.
You would then store the files on the device so they don't need to be downloaded again... and you could provide a UI to delete files the user no longer wants stored locally.

iOS application cannot access downloaded file when relaunched - UUID changes

I've been debugging a problem where my app successfully downloads a file and copies it to the Documents directory. Lately the app cannot open the downloaded file on subsequent launches of the app. I've been printing out file URLs and this is what I see when the file is initially downloaded and opened:
unzipped /var/mobile/Containers/Data/Application/9AC69C00-228E-482F-99D8-DD8F214FCE88/Documents/3.atcase to
/var/mobile/Containers/Data/Application/9AC69C00-228E-482F-99D8-DD8F214FCE88/Library/Application Support/thebundleID/current-case
You can see the UUIDs are the same, but when I launch the app again I see this:
couldn't unzip /var/mobile/Containers/Data/Application/9AC69C00-228E-482F-99D8-DD8F214FCE88/Documents/3.atcase to
/var/mobile/Containers/Data/Application/C18E7EFA-C0D0-4213-AF85-F5BC0D2A4207/Library/Application Support/thebundleID/current-case
This time the UUIDs appear to be different.
I will say tentatively that the answer is yes, the UUID used in the application container folder does seem to change every time the app is run, though I'd love to have some confirmation from a more experienced developer.
The solution to my problem was straightforward: Do not store absolute file URLs in the database. The URLs for the files are now constructed relative to the Documents directory URL every time the app is run. Since I name the files in a regular way, there is no need to store URLs anyway.

Which is permanent storage directory in iOS?

I need to store permanently (as far as app is not uninstalled from the device), the photos that are taken from camera roll and photo library into my app's bundle. Perviously i was storing those file in tmp folder, i read that the contents of tmp folder will be purged by iOS if it finds less memory for other app to run.. so my images were not getting displayed in my app after 3 or 4 days as IOS would have purged the content of tmp folder.
SO where do i need to Store these files? In Documents folder? is documents folder is permanent ?people say that you should not store huge amount of files in documents folder.. There is no limit for the photos that can be taken from my app. user may take 100 photos, 200photos, 500photos, or more than that.. its ok if user uninstall the application.. i will download all those photos in background once he login again. so what would you suggest for this problem? any kind of help is highly appreciated.
thanks
You put the files in the Documents folder, or if you can download them again from Internet, in the cache folder. If in Documents folder, you must mark the files with the attribute that prevents them from getting backed up to iCloud, or your app will be rejected.
Do that using this documentation:
https://developer.apple.com/library/ios/qa/qa1719/_index.html
These rules are enforced pretty vigorously by Apple and spelled out in:
https://developer.apple.com/icloud/documentation/data-storage/
(Requires iOS app developer login to view, I believe.)
What you are looking for here is SQLite. Using SQLite you can store your data and Images.
For storing the Images you can refer this link

Releasing IOS app with files in Library directory

I have an app that is going to display a list of local video files. The app will only have a couple of video files at first, but that number will grow with future updates and in-app purchases. I would like to store all these videos in 1 place and it makes sense to put them in the app's Library directory so they are not user-accessible. Is it possible to publish an app with files already in the app's Library directory? Or do I have to put them in the app's bundle and then copy them to the Library directory when the app is first launched? Although that would result in the 2 videos files being duplicated since I can't remove them from the bundle.
Yes, you do need to copy the files from the app bundle into the Library if you want to treat all the videos in the same way. You cannot change the contents of the app bundle from inside your app and the only files your app has when it first launches are those that are in the app bundle.
If you really wanted (and if the video files don't change), you could make special cases in your code to be able to get the starting videos from the app bundle and the in-app purchase downloaded videos from the Library directory. But, unless the video files are quite large this seems a bit excessive.
A third option would be to have the user download the starter files on first app launch, but that may be suboptimal for other reasons.
Please look at my answer in this thread. It might concern you or at least be interesting to read.
Does updating iOS apps delete library directory files?

Resources