I am creating a universal iOS app, which I would like to distribute with certain eBooks published by other authors. When a user purchases specific books, I would like to give them a free download of my app. For example, if my app is a glossary of statistical terms, I would like to offer my app for free when a user purchases a book such as "Statistics 101" or "Statistical Analysis of Stochastic Equations". 

I am willing to work with the author of the book to do what is necessary. But what I want to find out is how can I link the eBook purchase on iBooks with a free app download. If it means generating unique promo-code like numbers to redeem, how do I generate hundreds of them and have them individually served out?