c58d846057
Related Work Items: #416, #422, #423, #424
90 lines
2.4 KiB
C#
90 lines
2.4 KiB
C#
using System;
|
|
using FoxTube.Services;
|
|
using Microsoft.AppCenter.Crashes;
|
|
using Microsoft.Services.Store.Engagement;
|
|
using Windows.Services.Store;
|
|
using Windows.UI.Xaml.Controls;
|
|
|
|
namespace FoxTube.Utils
|
|
{
|
|
public static class FeedbackInterop
|
|
{
|
|
public static bool HasFeedbackHub => StoreServicesFeedbackLauncher.IsSupported();
|
|
|
|
public static async void OpenFeedbackHub()
|
|
{
|
|
if (HasFeedbackHub)
|
|
await StoreServicesFeedbackLauncher.GetDefault().LaunchAsync();
|
|
}
|
|
|
|
public static async void RequestStoreReview()
|
|
{
|
|
StoreRateAndReviewResult result = await StoreContext.GetDefault().RequestRateAndReviewAppAsync();
|
|
|
|
if (result.Status == StoreRateAndReviewStatus.Error)
|
|
Metrics.SendReport(result.ExtendedError, new[] { ErrorAttachmentLog.AttachmentWithText(result.ExtendedJsonData, "extendedJsonData.json") },
|
|
("Status", result.Status.ToString()),
|
|
("WasReviewUpdated", result.WasUpdated.ToString()));
|
|
|
|
Metrics.AddEvent("Store review request has been received");
|
|
}
|
|
|
|
public static async void PromptFeedback()
|
|
{
|
|
if (!HasFeedbackHub)
|
|
{
|
|
Storage.SetValue(Storage.Settings.PromptFeedback, false);
|
|
return;
|
|
}
|
|
|
|
ContentDialog dialog = new ContentDialog
|
|
{
|
|
Title = "Have some thoughts?",
|
|
|
|
PrimaryButtonText = "Sure!",
|
|
SecondaryButtonText = "Don't ask me anymore",
|
|
CloseButtonText = "Maybe later",
|
|
|
|
DefaultButton = ContentDialogButton.Primary,
|
|
|
|
Content = "Would you like to share something you like or dislike in the app? Or perhaps you have some ideas? Leave feedback!"
|
|
};
|
|
|
|
ContentDialogResult result = await dialog.ShowAsync();
|
|
|
|
if (result != ContentDialogResult.None)
|
|
Storage.SetValue(Storage.Settings.PromptFeedback, false);
|
|
|
|
if (result == ContentDialogResult.Primary)
|
|
OpenFeedbackHub();
|
|
}
|
|
|
|
public static async void PromptReview()
|
|
{
|
|
ContentDialog dialog = new ContentDialog
|
|
{
|
|
Title = "Like our app?",
|
|
|
|
PrimaryButtonText = "Sure!",
|
|
SecondaryButtonText = "Don't ask me anymore",
|
|
CloseButtonText = "Maybe later",
|
|
|
|
DefaultButton = ContentDialogButton.Primary,
|
|
|
|
Content = new TextBlock
|
|
{
|
|
Text = "Could you leave a feedback on Microsoft Store page? It's very important for me :)"
|
|
}
|
|
};
|
|
|
|
ContentDialogResult result = await dialog.ShowAsync();
|
|
|
|
if (result != ContentDialogResult.None)
|
|
Storage.SetValue(Storage.Settings.PromptReview, false);
|
|
|
|
if (result == ContentDialogResult.Primary)
|
|
RequestStoreReview();
|
|
}
|
|
}
|
|
}
|