download new stages for the app

Hello to all, 

I have an application that has 40 scenes(levels), if the user wants more levels he must buy them. 

But as the level have many images the application is a little big, and I would not want to leave the application scene that were not purchased, in order to decrease the size of the app. 

Is there anyway for when a purchase is made, a package of scenes and imagens is downloaded from the internet and installed on the device?

translated from Portuguese by google translator

It’s not the easiest thing to do, but it can be done.

  1. You need a site to host your download files.  Depending on the success of your app you will want to use a cloud service more than a low-end web host.

  2. You would process the In-App Purchase (You must be a Basic level subscriber to use IAP) and once you are notified that the transaction was a success, you can use network.download() to download the file to your app’s system.CachesDirectory folder for iOS or probably the system.DocumentsDirectory on Android.

  3. If your files are stored in a tar archive format, there is a free library in the Community contributed code area that will let you un-tar the file into a folder.  If you wish to use a .zip archive format, we have a plugin to unzip the archive, but you must be a Pro level subscriber to use it.

  4. Then your app can pick up the files and start using them

Rob

Hello Rob,

I need to compile the files or just need to put the files .lua in compressed tar? 

Any tutorial where I can observe the operation of that? 

Thanks for the feedback.

The .lua files will already have to be in your app.  Apple does not permit adding downloadable code.  Your zip file can contain the images and audio you need.  You can also use data files perhaps saved in JSON format that to act like loadable tables.  But any code to process that data has to already exist in your app.

Rob

Nice,

after downloading and unzipping the files, how do I move them to different folders? 

My app has folders of images for different languages​​. 

example: 

/img 

     here the default images for all languages 

/img/en 

/img/fr 

/img/en

I downloaded them where I wanted them, then removed the zip files when done.

Also note that the zip/unzip plugin supports zip archives which have directory structures in them. This means, if you set your source file to contain the same directory tree then when you unzip it you will end up with the directory tree you wish to have on your destination and the files will already be placed where they need to be placed. One less thing to worry about then.

It’s not the easiest thing to do, but it can be done.

  1. You need a site to host your download files.  Depending on the success of your app you will want to use a cloud service more than a low-end web host.

  2. You would process the In-App Purchase (You must be a Basic level subscriber to use IAP) and once you are notified that the transaction was a success, you can use network.download() to download the file to your app’s system.CachesDirectory folder for iOS or probably the system.DocumentsDirectory on Android.

  3. If your files are stored in a tar archive format, there is a free library in the Community contributed code area that will let you un-tar the file into a folder.  If you wish to use a .zip archive format, we have a plugin to unzip the archive, but you must be a Pro level subscriber to use it.

  4. Then your app can pick up the files and start using them

Rob

Hello Rob,

I need to compile the files or just need to put the files .lua in compressed tar? 

Any tutorial where I can observe the operation of that? 

Thanks for the feedback.

The .lua files will already have to be in your app.  Apple does not permit adding downloadable code.  Your zip file can contain the images and audio you need.  You can also use data files perhaps saved in JSON format that to act like loadable tables.  But any code to process that data has to already exist in your app.

Rob

Nice,

after downloading and unzipping the files, how do I move them to different folders? 

My app has folders of images for different languages​​. 

example: 

/img 

     here the default images for all languages 

/img/en 

/img/fr 

/img/en

I downloaded them where I wanted them, then removed the zip files when done.

Also note that the zip/unzip plugin supports zip archives which have directory structures in them. This means, if you set your source file to contain the same directory tree then when you unzip it you will end up with the directory tree you wish to have on your destination and the files will already be placed where they need to be placed. One less thing to worry about then.