Stars Rating, App

High ratings in the Google Play Store or iOS App Store are critical to an app’s success. And they’re beneficial to find out what the problems are when an app needs improvement. So, it’s very common to have a simple link/button that allows the end user to submit their review from inside the app. The less hoops to jump through, the better.

As a developer creating a cross-platform app, there’s also the desire to keep a single codebase. Luckily with Cordova (used with PhoneGap, Ionic, and other HTML-based app frameworks), there is a way to test which platform is currently running.

URL Formats for Android & iOS

Both iOS and Android have a URL format that will allow you open the app directly in the native store (not in the browser):

Google Play:

market://details?id=com.YOURPACKAGE.YOURPACKAGE

Replace after id= with your app’s package name (the standard naming convention is com.yourdomainname.yourappname). This link will open up in the Play Store, where the star rating is front and center.

App Store:

itms-apps://itunes.apple.com/us/app/YOUR-APP-SLUG-URL/id1111111111111?mt=8&uo=4

Where can you find this? After your app is submitted to Apple using iTunes Connect, you will be able to find this URL on your app store link. In iTunes Connect, this is currently under More -> View on App Store. Your best bet is to use the official iTunes Link Maker. Then you can replace https with itms-apps.

If you’re testing this out in the device simulator in XCode, you may get an error: “Failed to load webpage with error: The URL can’t be shown.” This is simply because the simulator does not have the App Store app installed. So the link has nothing to open up in. I received this error in the simulator, and the link worked fine on an actual device.

Some more info here:

You may also be wondering what the mt and uo parameters are on that URL. The mt is a number that designates the Media Type; music, mobile software, audiobooks, etc. The uo is the Unique Origin, that is used to track where the link was generated. You may be able to remove that parameter, but oddly enough I can’t find the official docs on it, to confirm that 100%.

Blackberry:

http://appworld.blackberry.com/webstore/content/APPLICATIONID

Opening the Link Depending on the Platform Running

To detect what platform is being run on the device, there is a Device API plugin available: org.apache.cordova.device. Besides the platform, this gives you access to other info such as the model name, UUID, and version. Note that “As of version 3.0, Cordova implements device-level APIs as plugins. Use the CLI’s plugin command“. If you’re using a local command line to build your PhoneGap app, this means that you’ll need to use the plugin add command.

cordova plugin add org.apache.cordova.device

And if you’re using the PhoneGap Build service (where you upload your files to compile in the cloud), you’ll want to add the plugin to your config.xml file.

<gap:plugin name="org.apache.cordova.device" />

Once you have access to the plugin, you can use the following in JavaScript to find out the operating system name.

var stringName = device.platform;

Here’s a full example, which uses jQuery Mobile to handle the tap/click of the button.

*Image Source: Creative Commons “Star Trails2” via Flickr (CC BY-SA 2.0)

Comments on this Article

  1. Maruthi says:

    Helpful information. could you please provide URL format for windows phone too.

    Thanks

    • Josh says:

      According to this it’s http://windowsphone.com/s?appId={GUID}

  2. antonyF says:

    android store link not supported anymore..

Leave a Reply

You can use the <pre> tag to post a block of code, or <code> to highlight code within text.