Local Purchase Check

Man, this should be easy…but I’m having trouble working through the best way to do this.

Here is what I’m looking for…I plan on offering an audio upgrade in my app. So basically you have audio file A that will be replaced with audio file B upon successful purchase.

It’s quite possible that my users WILL NOT have internet access at some point after they’ve made the purchase, so I need to figure out the best way to track purchases locally so that the app knows whether to serve up file A or file B.

What is the best/most efficient way to do this? I have lots of different ideas, but they all seem more complicated than this should be. Any thoughts?

Thanks in advance.

Brian
[import]uid: 141982 topic_id: 32980 reply_id: 332980[/import]

I should add that my current thought is to just os.remove file A and then os.rename file B to file A. That’s probably the easiest way to do it, no?

I’m also thinking of giving the user a switch to toggle between audio files. So the above would not work…I’d need to store the purchased state somehow. [import]uid: 141982 topic_id: 32980 reply_id: 130942[/import]

I should add that my current thought is to just os.remove file A and then os.rename file B to file A. That’s probably the easiest way to do it, no?

I’m also thinking of giving the user a switch to toggle between audio files. So the above would not work…I’d need to store the purchased state somehow. [import]uid: 141982 topic_id: 32980 reply_id: 130942[/import]

If you are downloading the upgraded content, one approach would be to create a folder for your app in the users Documents directory, and store the downloaded/purchased content there. To create the folder, and move files around, you should see:

http://www.coronalabs.com/blog/2012/05/08/luafilesystem-lfs-tutorial/

When it’s time to play content, you can first check the downloaded content / upgrade folder for the file, and if not there, fallback to the original file.

If you are shipping with the upgraded content already included with your app, there’s several ways to approach it. You could create a content list you store on the device which lists what audio has been purchased (adding to the list each time they purchase content). You’d probably want to encrypt this on the device, if you go this route. (do a search, corona has encryption API’s).

Best of luck.

Note: I don’t think you can reliably delete files from your games resource directory on the device, as you suggested above. I believe on Android, the game is actually run out of a zip type archive, so file modifications on app resource files aren’t permitted (dunno about ios). [import]uid: 79933 topic_id: 32980 reply_id: 130952[/import]

If you are downloading the upgraded content, one approach would be to create a folder for your app in the users Documents directory, and store the downloaded/purchased content there. To create the folder, and move files around, you should see:

http://www.coronalabs.com/blog/2012/05/08/luafilesystem-lfs-tutorial/

When it’s time to play content, you can first check the downloaded content / upgrade folder for the file, and if not there, fallback to the original file.

If you are shipping with the upgraded content already included with your app, there’s several ways to approach it. You could create a content list you store on the device which lists what audio has been purchased (adding to the list each time they purchase content). You’d probably want to encrypt this on the device, if you go this route. (do a search, corona has encryption API’s).

Best of luck.

Note: I don’t think you can reliably delete files from your games resource directory on the device, as you suggested above. I believe on Android, the game is actually run out of a zip type archive, so file modifications on app resource files aren’t permitted (dunno about ios). [import]uid: 79933 topic_id: 32980 reply_id: 130952[/import]