Home

Awesome

Xamarin.Plugins

Xamarin.Plugins by VoxDev

##Store Rating Plugin for Xamain.Forms

Display a store rating dialog after a certain number of uses, or a certain number of days after installation or on demand (eg on button tap). The user can leave a rating, delay giving a rating or decline to give a rating.

The rating dialog brings up the relevant store page. If the rating request is declined then a feedback dialog is shown which sends an email to the developer.

Store Rating Plugin for Xamain.Forms

Store Rating Plugin for Xamain.Forms

###Settings

The plugin properties can be set once in the shared App.cs file

StoreRatingControl.AppName = "My App";
StoreRatingControl.FeedbackEmail = "myemail@mycompany.com";
StoreRatingControl.IncUsage();

####Required Settings

####Optional Settings

###Manually Display the Rating Dialog

The Rating dialog can be shown manually, for example on a button click

Button btnRate = new Button
{
    Text = "Rate Now!",
    VerticalOptions = LayoutOptions.CenterAndExpand,
    HorizontalOptions = LayoutOptions.CenterAndExpand,
};
btnRate.Clicked += ((s, e) =>
{
    _ratingControl.ShowRating();
});

###Required Initialisation To ensure that the control does not get linked out in the application the Init methods must be called just after the Xamarin.Forms.Init() in each of the 3 platform specific projects (MainPage.xaml.cs, AppDelegate.cs and MainActivity.cs).

Forms.Init();
StoreRating.Forms.Plugin.WindowsPhone.RatingService.Init();
StoreRating.Forms.Plugin.WindowsPhone.SendMailService.Init();

###Usage Create a StoreRatingControl object and place in a grid on top of your existing page in position (0,0).

	public class App
	{
        private static StoreRatingControl _ratingControl;

		public static Page GetMainPage()
		{
            StoreRatingControl.AppName = "My App";
            StoreRatingControl.AppID = "0123456789";
            StoreRatingControl.FeedbackEmail = "myemail@mycompany.com";
            StoreRatingControl.IncUsage();
            //StoreRatingControl.Preview = true;

            Grid grTopLevel = new Grid
            {
                Padding = 0,
                BackgroundColor = Color.Blue,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions = LayoutOptions.FillAndExpand,
                RowDefinitions = 
                    {
                        new RowDefinition{ Height = new GridLength(1, GridUnitType.Star) },
                    },
                ColumnDefinitions = 
                    {
                        new ColumnDefinition{ Width = new GridLength(1, GridUnitType.Star) },
                    },
            };

            Button btnRate = new Button
            {
                Text = "Rate Now!",
                VerticalOptions = LayoutOptions.CenterAndExpand,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
            };
            btnRate.Clicked += ((s, e) =>
            {
                _ratingControl.ShowRating();
            });

            StackLayout sl = new StackLayout
            {
                Orientation = StackOrientation.Vertical,
                Children =
                {
                    new Label {
					    Text = "Hello, Forms !",
					    VerticalOptions = LayoutOptions.CenterAndExpand,
					    HorizontalOptions = LayoutOptions.CenterAndExpand,
				    },
                    btnRate
                }
            };

            grTopLevel.Children.Add(sl, 0, 1, 0, 1);

            _ratingControl = new StoreRatingControl();
            grTopLevel.Children.Add(_ratingControl, 0, 1, 0, 1);

			return new ContentPage
			{
                Content = grTopLevel
			};
		}
	}

###Usage Counter To use the usage counter, you need to call the increment function each time the app starts (such as in the shared App.cs file)

StoreRatingControl.AppName = "My App";
StoreRatingControl.FeedbackEmail = "myemail@mycompany.com";
StoreRatingControl.IncUsage();

###License Licensed under MIT see License file