Adding App Rating Functionality in App Using Review Task

Introduction

This article explains the Marketplace Review Task. This task helps to launch the Rating Screen in the marketplace for our app. It can be used for adding the rating mechanism to an APP.

Marketplace Review Task

This is a kind of launcher provided by Windows Phone to launch the rating screen for an app on the Windows Phone marketplace. This task expects no parameters to be set and works on the basis of app id. 

Before using this task we need to include the following namespace:

using Microsoft.Phone.Tasks;

Use the following procedure to use it:

  1. Create a new instance of a marketplace review task.

    Microsoft.Phone.Tasks.
    MarketplaceReviewTask mrt = new MarketplaceReviewTask()
     
  2. Next launch it.

    mrt.Show();

Demo

The following code demonstrates how to add a rating mechanism to your app. For this rating task to work your app needs to be published on the marketplace first. Since this is just a demo and it's not published on the marketplace, to run this project you need to change the "APP ID" to the one for your published app.

Use the following procedure to change the app id:

  1. Open the "WMAppManifest.xml" file.
     
  2. Click on the Packaging tab.
     
  3. Now copy your existing Product id to some secure place.
     
  4. Replace this product id with the published app id.
     
  5. Save all the changes.
     
  6. Rebuild the project and debug it.
     
  7. After debugging and before releasing, don't forget to replace the app id with the one you saved earlier.

 

XAML

<phone:PhoneApplicationPage

    x:Class="Demo.MainPage"

    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"

    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"

    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"

    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"

    mc:Ignorable="d"

    FontFamily="{StaticResource PhoneFontFamilyNormal}"

    FontSize="{StaticResource PhoneFontSizeNormal}"

    Foreground="{StaticResource PhoneForegroundBrush}"

    SupportedOrientations="Portrait" Orientation="Portrait"

    shell:SystemTray.IsVisible="True">

 

    <!--LayoutRoot is the root grid where all page content is placed-->

    <Grid x:Name="LayoutRoot" Background="Transparent">

        <Grid.RowDefinitions>

            <RowDefinition Height="Auto"/>

            <RowDefinition Height="*"/>

        </Grid.RowDefinitions>

 

        <!--TitlePanel contains the name of the application and page title-->

        <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">

            <TextBlock Text="Demo" Style="{StaticResource PhoneTextNormalStyle}" Margin="12,0"/>

            <TextBlock  Text="Demo" Margin="9,-7,0,0" FontSize="40" />

        </StackPanel>

 

        <!--ContentPanel - place additional content here-->

        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">

            <StackPanel Orientation="Vertical">

                <TextBlock Text="Rate this App" FontSize="45" Height="106"></TextBlock>

                <TextBlock Text="Click Below Button to Rate This App" FontSize="25" Height="106"></TextBlock>

                <Button Name="sendBtn" Click="sendBtn_Click"  Content="Rate App" HorizontalAlignment="Left" Width="186" Height="80" VerticalAlignment="Bottom" Margin="132,0,0,0"/>

            </StackPanel>

        </Grid>

    </Grid>

</phone:PhoneApplicationPage>

C# Code Behind

using Microsoft.Phone.Controls;

using System;

using System.Collections.Generic;

using System.Linq;

using System.Net;

using System.Windows;

using System.Windows.Controls;

using System.Diagnostics;

using Microsoft.Phone.Tasks;

using System.Windows.Media;

 

namespace Demo

{

    public partial class MainPage : PhoneApplicationPage

    {

        // Constructor

        public MainPage()

        {

            InitializeComponent();

        }

 

        private void sendBtn_Click(object sender, RoutedEventArgs e)

        {

            /* Step 1 */

            Microsoft.Phone.Tasks.MarketplaceReviewTask mrt = new MarketplaceReviewTask() ;

            /* Step 2 */

            //none

            /* Step 3 */

            mrt.Show();

 

        }

    }

}

The Show method is used to launch the task.

Output

 

Up Next
    Ebook Download
    View all
    Learn
    View all