我建議不要在第一次打開應用程序時提示'評價我的應用程序',因爲應該給用戶一些時間來查看應用程序的外觀和功能。因此,保持應用程序啓動數量並要求在應用程序的第5次至第10次啓動後對應用程序進行評級將更有意義。此外,你應該檢查你是否已經提示用戶評價你的應用程序,如果沒有再次提示。 (否則,你會因'評價我的應用程序'而惹惱他們)
爲了達到這個目的,你應該首先保持應用程序設置類中的應用程序啓動計數。
用於存儲任何類型的設置界面:
public interface ISettingService
{
void Save();
void Save(string key, object value);
bool AddOrUpdateValue(string Key, object value);
bool IsExist(string key);
T Load<T>(string key);
T GetValueOrDefault<T>(string Key, T defaultValue);
}
該評級服務類消耗上述接口存儲這樣的數量和設置:
public class RatingService
{
private const string IsAppRatedKeyName = "isApprated";
private const string TabViewCountKeyName = "tabViewCount";
private const bool IsAppratedDefault = false;
private const int TabViewCountDefault = 0;
private const int ShowRatingInEveryN = 7;
private readonly ISettingService _settingService;
[Dependency]
public RatingService(ISettingService settingService)
{
_settingService = settingService;
}
public void RateApp()
{
if (_settingService.AddOrUpdateValue(IsAppRatedKeyName, true))
_settingService.Save();
}
public bool IsNeedShowMessage()
{
return (_settingService.GetValueOrDefault(TabViewCountKeyName, TabViewCountDefault)%ShowRatingInEveryN) == 0;
}
public void IncreaseTabViewCount()
{
int tabCount = _settingService.GetValueOrDefault(TabViewCountKeyName, TabViewCountDefault);
if (_settingService.AddOrUpdateValue(TabViewCountKeyName, (tabCount + 1)))
_settingService.Save();
}
public bool IsAppRated()
{
return _settingService.GetValueOrDefault(IsAppRatedKeyName, IsAppratedDefault);
}
}
這是你將如何運行這樣功能,並提示用戶對項目中任何位置(主頁面或用戶啓動某些功能的其他頁面)進行評分(如果以前未評分):
private void RunRating()
{
if (!RatingService.IsAppRated() && RatingService.IsNeedShowMessage())
{
MessageBoxResult result = MessageBox.Show("Review the app?", "Would you like to review this awesome app?",
MessageBoxButton.OKCancel);
//show message.
if (result == MessageBoxResult.OK)
{
RatingService.RateApp();
new MarketplaceReviewTask().Show();
}
}
}
好的我已經找到了MainPage.xaml.cs的位置 - 在解決方案資源管理器中的MainPage.xaml下嵌套,所以我想我要弄明白了。 –
對不起,但開發問題必須問在Stackoverflow。 –