Tip: Rate My App – AIR style

Working on a mobile game or app with AIR mobile, one of the common tasks is putting a rate alert box – some sort of rating request that prompts the user to leave a review on the App store. This can be something like this:

One way to achieve that would be with a native extension (ANE). There are also plenty of examples of how to code it in native Android or iOS, but with AIR we want to address all platform with the same code, if possible.

I will show an easy way to do just that in your AIR mobile app with just plain old AS3, and handle both Apple and Google app stores.

The first part is showing the prompt. Just use your favourite UI component or your own popup skin to create and show a popup with two buttons. You are not restricted to UIKit style or Android style – I always like to customize it the same style of the game/app.

Next, we need to get the App id for the app store. In the case of iOS, this would be the ‘AppStore ID’ provided when you submit your app – a numerical ID. To find it, log into iTunesConnect and go to ‘Manage Your Applications’ and select your app. This will show a page like this:

In the details page above, the Apple ID value (numerical) is the ID required.

For Android we use Google Play store ID. This is more straight forward – just use the app ‘id’ declared in your AIR app.xml (in the id tag). However, the ADT adds an ‘air’ prefix to the id, so this would be something like ‘air.com.mydomain.myapp’.

On the click handler for the ‘rate’ button place a call:

// handle 'rate'
openRatePage();

The app store page is accessible from the app simply by navigating to the right URL. When run on the device, this will open the App Store (or Play store) right on the app page, so the user can place a review.

That is all.
Note that the code will not work when running on desktop (simulator), so you will need to create a build and install it on a device to actually test it.

Another common problem is that the app is not yet in the store, or not yet submitted, so the app page will not be found. The simple way around it is to borrow an ID from another app that’s already in the store and use it for testing. For example, Temple Run (Apple ID: 420009108, Google ID: com.imangi.templerun).
Once everything is working, place back your app ID before making the final build.