当他们第五次打开我的应用程序时,我试图让应用程序审查提示出现,但我似乎没有任何运气。我试过在这个网站上使用代码,但它对我不起作用。还有其他人知道的吗?
connection/archive/2013/07/25/prompting-for-feedback-within-your-windows-phone-or-windows-8-app-game.aspx
async protected override void OnLaunched(LaunchActivatedEventArgs e)
{
#if DEBUG
if (System.Diagnostics.Debugger.IsAttached)
{
this.DebugSettings.EnableFrameRateCounter = true;
}
#endif
Frame rootFrame = Window.Current.Content as Frame;
// Do not repeat app initialization when the Window already has content,
// just ensure that the window is active
if (rootFrame == null)
{
// Create a Frame to act as the navigation context and navigate to the first page
rootFrame = new Frame();
// Set the default language
rootFrame.Language = Windows.Globalization.ApplicationLanguages.Languages[0];
rootFrame.NavigationFailed += OnNavigationFailed;
if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
{
//TODO: Load state from previously suspended application
}
// Place the frame in the current Window
Window.Current.Content = rootFrame;
}
if (rootFrame.Content == null)
{
// When the navigation stack isn't restored navigate to the first page,
// configuring the new page by passing required information as a navigation
// parameter
rootFrame.Navigate(typeof(MainPage), e.Arguments);
}
// Ensure the current window is active
Window.Current.Activate();
int started = 0;
if (Windows.Storage.ApplicationData.Current.RoamingSettings.Values.ContainsKey("started"))
{
started = (int)Windows.Storage.ApplicationData.Current.RoamingSettings.Values["started"];
}
started++;
Windows.Storage.ApplicationData.Current.RoamingSettings.Values["started"] = started;
if (started == 3)
{
var md = new Windows.UI.Popups.MessageDialog("Thank you for using this app?", "Please review my app");
bool? reviewresult = null;
md.Commands.Add(new Windows.UI.Popups.UICommand("OK", new Windows.UI.Popups.UICommandInvokedHandler((cmd) => reviewresult = true)));
md.Commands.Add(new Windows.UI.Popups.UICommand("Cancel", new Windows.UI.Popups.UICommandInvokedHandler((cmd) => reviewresult = false)));
await md.ShowAsync();
if (reviewresult == true)
{
string familyName = Package.Current.Id.FamilyName;
await Windows.System.Launcher.LaunchUriAsync(new Uri(string.Format("ms-windows-store:REVIEW?PFN={0}", familyName)));
}
}
}发布于 2015-04-09 01:17:38
在应用程序初始化到可以启动MessageDialog之前,您将调用它。
如果您查看正在复制的这篇文章,您将看到它将在调用OnLaunched ()之后将新代码放在Window.Current.Activate()方法的底部,而不是在OnLaunched方法的开头。
如果您这样做,那么对话框将按需要工作。
https://stackoverflow.com/questions/29520539
复制相似问题