in-app purchase best practise: how to use what is downloaded
simple example of the problem: i have an app that can download backgrounds from in-app purchase. so i downloa开发者_开发问答d images (or a zipped image). now that i have it on my iphone...how can my app knows the name of the image and can load as background of the game?
what i have thought is zip of the image+downloaded.plist; downloaded.plist is a filename that contains the name of what i have downloaded, so my app loads that plist (i know the name because is always equal) and then the rest... but now i have to save that information in another local plist that contains all add-on downloaded...
this is a very basic example, but i can in future load levels, character...so i'd like to know how to organize work to have it more general as possible...
what is the standard method to make this? thanks
I am not quite sure I understood your question, but here are some thoughts.
When the user buys something using iap, you know the associated product id. With that, you can map to the actual thing the user has bought (whether it is an image, a level, cash, whatever). So, you should use the product identifier to know that to give to the user.
It seems you are dealing with non-consumable products here. If you ship your app with the products inside the bundle, you can unlock them using the product id (As you said, you need to maintain a list of the unlocked files). If you need to download the products, the same applies here, you need to use the id to know which file to download.
To organize work, I would implement a store object that deals with the store kit, loads the products according to the transactions made, gives them to the user, maintains all the necessary stuff, etc. You can escale this approach to a set of classes if necessary.
On a side note, for non consumable products, you should perform several things on a server, e.g. maintain the list of products the user bought, validations, etc. You can read about this in the in-app purchases programming guide from Apple.
I hope this answers your question.
Cheers
精彩评论