How To Generate Your Own Unlock Code?

iOS Development: What's an easy way to generate an unlock code from a string that can be validated in the app?

  • I'm diving into iOS development and I just built my first game. Since Apple controls all the In-App purchases, they make it difficult for me to provide my customers with free content if I so choose. As such, I'd like to be able to email a single customer a single unlock code they can use to unlock an In-App purchase, but that code can only be used by that one single customer and I won't have any kind of a server to validate it. So my idea is to have the user email me their Game Center username and I use that to generate the code and add a check in my app to limit the number of unlocks to one per app (that way they can't just create a bunch of Game Center accounts and unlock all the IAPs). What's an easy way to generate an unlock code from a string (in this case, their Game Center username) that can be validated in the app? Thanks so much for your wisdom! *UPDATE* The simplest solution to this is to use the hash method of the NSString class.

  • Answer:

    You could do some sort of hash. You can read up on doing an MD5 hash. This lets you generate a unique code from any string. A good strategy could be to make a string that is a combination of a username and device id (UUID which can be accessed programmatically). Have your app generate the code and mail from within the app. There probably several other ways to accomplish this too.

BeachRunnerFred at Stack Overflow Visit the source

Was this solution helpful to you?

Other answers

I think that sort of unlock code is pretty much the same as license key tied to a username. In that case, this article might be of interest: http://sigpipe.macromates.com/2004/09/05/using-openssl-for-license-keys/ by Alan Odgaard.

Anh

Nope, you can't do this. IAP (unless something has changed that I don't know about) doesn't work with promotional codes. (Also, if you're planning on doing this for more than a couple customers, then it wouldn't work anyway, since you get a limited number of promotional codes per app version). But nothing's stopping you from providing your own free content outside of IAP! Apple has no problem with providing extra free content inside your app. But the point is that if you are also selling it with IAP, you need to be sure that the user isn't paying for it somewhere else, and then getting it for free (since then, Apple will see that you're circumventing their cut of the purchase). If you do go this route, you'll probably want to have some sort of server where you can check and redeem users' requests for free content. Urban Airship may have something along these lines, I think.

Jonathan Sterling

See http://blog.mugunthkumar.com/coding/introducing-mkstorekit-%E2%80%93-version-3/. You can allow certain UUIDs to have free access to iAPs.

Alexsander Akers

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.