James Montemagno
James Montemagno

Live, Love, Bike, and Code.

Tags


Twitter


Opening App Store for Ratings on iOS and Android

James MontemagnoJames Montemagno

Sometimes you want to ask your users to rate your application. There are several components out there that will open a dialog box and prompt for ratings, but sometimes you don’t want to stop the flow of your app and throw it in their face. What I do in my application is simply add a section on my settings page asking if they would like to rate the app. When pressed I launch the app store directly to the review page:

This is pretty simple to do for iOS and Android by launching a specific URL scheme. To do this, we will use two differnt plugins:

For iOS you will need to decide what URL you want to use based on the OS versions you support as each have different URLs:

* **Lower than iOS 7:** ``` itms-apps://itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=YOUR_APP_ID ```
  • iOS 7:
itms-apps://itunes.apple.com/app/idYOUR_APP_ID
  • iOS 8 or later:
itms-apps://itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?id=YOUR_APP_ID&onlyLatestVersion=true&pageNumber=0&sortOrdering=1&type=Purple+Software

I only target iOS 8 and later so I will use that item. All you need to do is replace the “YOUR_APP_ID” with your actual APP ID from your iTunes connect page.

Update! Recently Apple updated the store to simply append on action=write-review onto the end such as:

var url = $"itms-apps://itunes.apple.com/app/id{appId}?action=write-review";

From the looks of it this works all the way back to iOS 8.

For Android, simply you will need the URL of your app on Google Play:

https://play.google.com/store/apps/details?id=YOUR_APP_ID

The Code! Let’s do this

It is actually really simple now:

var url = string.Empty;
var appId = string.Empty;

if(CrossDeviceInfo.Current.Platform == Platform.iOS)
{
    appId = "your_id";
    url = $"itms-apps://itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?id={appId}&onlyLatestVersion=true&pageNumber=0&sortOrdering=1&type=Purple+Software"
}
else if(CrossDeviceInfo.Current.Platform == Platform.Android)
{
    appId = "your_id";
    url = $"https://play.google.com/store/apps/details?id={appId}"
}

if(string.IsNullOrWhiteSpace(url))
  return;

await CrossShare.Current.OpenBrowser(url, new BrowserOptions
{
    UseSafariWebViewController = false
);}

Boom, there you have it! The app store for both iOS and Android will open up and you are good to go.

Enjoy!

Live, Love, Bike, and Code

Comments