I’m working on an iPhone app with inApp payment: whenever the user pays a small sum, he receives an update of the application. The “update” is a sort of new “chapter” in an adventure game and it is made of text and xml files, images, sounds and so on, generically “assets”. When the assets are downloaded, they form the content of a new chapter (or stage, or step) inside the application.
I’m looking for advices on how to load all this data: for example, the device, while downloading, could accidentally stop working (low battery, etc.) or it could disconnect for some reason. This way, the integrity of the update would be lost. I researched a little and found solutions with md5 checksum or sockets, but I wanted to ask here too, before starting anything. For example, I wanted to know if it is a good idea to download a big zip file or it would be better to download small uncompressed files.
Any advice is appreciated. Thank you.
I have a similar setup, and what I do is maintain a database of items installed. I also have a separate list of items available which is updated from my server periodically.
When the user buys one, the item is copied from the “available” list to the “installed” list with a status of “purchased”. It then goes into a download queue.
After it’s downloaded, the status is moved to “downloaded” and some installation is done. Then the status is finally updated to “installed”.
I protect against interruptions by having the app check when it starts (or is unbackgrounded) for any items in the “installed” list that don’t have a status of “installed”. And depending on the status, I either restart the download or redo the installation.
As for file integrity, I just check for a known header, but an md5 or other checksum would be better.
Update: My app only downloads a single file (sqlite database), so if it gets interrupted it has to start over from the beginning. I enabled deflate on my web server, which NSURLConnection supports, so compression is done transparently. But I’m sure your interest in using a zip file is primarily to make downloading simpler. I had considered using a zip file at one point too, but I was unable to find an easy way to extract it.