Add InApp-Purchases on Android & iOS

A few months ago, I decided to add an Upgrade option to one of my apps: TouchUp Lite for iOS. I wanted to use the In App Purchase API to allow people to instantly upgrade their Lite version to Pro.

It turned out to be one of the best decisions I’ve ever made. Since then my revenues have basically doubled for that App. And now,  after months of slow and steady growth, income from TouchUp Lite Upgrade has exceeded sales of the TouchUp Pro as a standalone app!

Here you can see the steady growth of the In App Purchase revenue:

 Note: Christmas leading into January creates a major sales bump that lasts a while, but seems to be fading…

So, given that experience, it was a no-brainer that I need to do the same thing with my upcoming editor PicShop. The rest of this post will walk about how you do this in Adobe AIR.
If you just wanted the growth numbers, you can leave now :)

How?

Adobe AIR does not support In App Purchases for any platforms out of the box, in order to enable it you must use things called Actionscript Native Extensions, or ANE’s. You can think of an ANE as a SWC by a different name, you include it in your FlashBuilder 4.6 project, and then you can make API calls on it just like you would a SWC.

When I added the initial IAP support for TouchUp Lite on iOS, I used a free ANE which you can find here:
http://code.google.com/p/in-app-purchase-air-ios/

That ANE works just fine, but it does have an annoying bug where it dispatches lots of extra events in certain edge cases (complete, cancelled, etc). Still it’s free, so if you need something on the cheap, give this a run.

For PicShop though, I need to support Android, and I also wanted a better iOS implementation because the extra events coming from the extension were a pain in the ass to deal with. Luckily, I found Milkman Games!

Milkman offers InApp Purchase ANE’s for both Android and IOS, complete with full documentation. They are not free though, and will cost you about $50 USD each.  In my books, that’s about 1-2hrs worth of work, so I think it’s an absolute steal.

Each extension comes with a lengthy tutorial on setting up each store, as well as complete ASDOC documentation. You can preview the API’s here:

Going over the actual implementations is outside of the scope of this Article, but really there’s not much to say. If you look at the ASDocs, you’ll see that the API is extremely straightforward, and the documentation takes care of explaining any grey areas. Honestly, setting up the data in the App Store(s) is the hardest part, once you get to the AS3 implementation you’re past the tough stuff…

I was especially impressed with how the documentation took the time to cover all the various edge cases that I didn’t even know existed, talk about sharing the knowledge! Not only was the code well documented, but the email support from Milkman Games was some of the best I’ve ever experienced.

All in all, it took just 6 hours for UI work, and another 4 hours to wire up both Android and iOS support. 10 hours in total, and a $100, for 2 platforms and potentially tens of thousands of dollars of potential revenue. Now that’s a good days work!

The iOS version is still awaiting approval, but you can check out the finished Android version here:
https://market.android.com/details?id=air.ca.esdot.PicShop.Lite

NOTE: This gives an interesting opportunity to compare Android and iOS IAP Numbers, since I have two free apps launching at the same time across both platforms. If you’re interested in seeing how the numbers compare and grow, subscribe to the blog. I’ll post updates every month or two. Thanks for reading  :)

Written by

7 Comments to “Add InApp-Purchases on Android & iOS”

  1. Emil says:

    Hello Shawn,
    Nice article :) I’m pretty impressed that the numbers are growing following this strange trend but it makes sense. Many people just spread around that the Lite version of the app is good and many others decided to try it. After some time they upgrade to full-version app.

    Thank you!

  2. Scott says:

    In looking through the Milkman purchase API, I don’t see any coverage for finishTransaction (detailed here: http://developer.apple.com/library/ios/#documentation/NetworkingInternet/Conceptual/StoreKitGuide/MakingaPurchase/MakingaPurchase.html#//apple_ref/doc/uid/TP40008267-CH3-SW1) like the Google Code ANE has.

    How is this handled?

  3. Jonathan Kaye says:

    How did you set up the data in the App Store, particularly:

    - What did you upload for the in-app binary (if anything)

    - How did you get it to recognize the in-app binary without having to get Apple to review it? I don’t want to submit my app for review because I don’t want Apple to review it — I need to test it first.

    I don’t see any included instructions on arranging the uploaded data. Thanks!

    • shawn says:

      When you buy the extension it comes with full instructions. Basically you just need to submit a placeholder version of the app and you can start testing against it. No changes to the banary other than including the ANE.

  4. I bought the extension from Milkman Games but am running into a problem, maybe you saw it in your testing (I am corresponding with the author about it, but it doesn’t sound like something he has run into).

    When I follow the example and instrux for a non-consumable, it asks me (on my iPad):

    1. Confirm Your in-app purchase [Environment Sandbox]
    2. Gets my Apple ID/password
    3. Verification Required [Environment: Sandbox]
    4. Password again
    5. Goes to the app store
    6. dialog box with [Environment: Sandbox], background box says “Loading…”
    7. Password again

    Then it endlessly repeats steps 6 and 7, never completing the purchase.

    Did you see anything like this? Thanks for any insights you might provide.

Leave a Reply to Jonathan Kaye

Message