Answered by:
Prompt user for app feedback not working

Question
-
I'm trying to get an app review prompt to appear when they have opened my app for the 5th time but I don't seem to be having any luck. I've tried using the code on this site but it doesn't work for me. Are there any other ones available that anyone knows of?async protected override void OnLaunched(LaunchActivatedEventArgs e) { 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 == 10) { 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))); } } #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(); }
Wednesday, April 8, 2015 8:31 PM
Answers
-
You'll do something essentially like you have in your previous code and as discussed at http://blogs.msdn.com/b/uk_faculty_connection/archive/2013/07/25/prompting-for-feedback-within-your-windows-phone-or-windows-8-app-game.aspx
Store a value in local (or roaming) settings to track if you should or should not show the dialog.
- Proposed as answer by Jamles HezModerator Tuesday, April 28, 2015 12:30 PM
- Marked as answer by Jamles HezModerator Wednesday, April 29, 2015 1:56 PM
Monday, April 20, 2015 11:14 PMModerator
All replies
-
In what way does this not work?
What is the actual behaviour you get, and how does that differ from what you expect?
Wednesday, April 8, 2015 8:44 PMModerator -
The message box does not appear as expected after launching my app several timesWednesday, April 8, 2015 8:55 PM
-
I would figure out if the issue is with the 'started' counter or elsewhere first.
Comment out the if(started == 10) or use a breakpoint to make sure there is nothing wrong there (though the code looks correct).
Visit http://blog.grogansoft.com/ for Windows development fun.
Thursday, April 9, 2015 12:53 AM -
You're calling it before the app is initialized to the point where it can start the MessageDialog.
If you look at the article you're copying from you'll see that it says to put the new code at the bottom of the OnLaunched method after the call to Window.Current.Activate(), not at the beginning of the OnLaunched method.
- Proposed as answer by Jamles HezModerator Tuesday, April 28, 2015 12:31 PM
Thursday, April 9, 2015 1:16 AMModerator -
I understand but it still doesn't work for me for some reason. Check my code below:
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))); } } }
Sunday, April 12, 2015 12:24 PM -
When my app launches a message box is shown. How can I prevent it from being shown again so that when the user taps the "Don't show again" button, the message box doesn't launch the next time it is opened?
async protected override void OnLaunched(LaunchActivatedEventArgs e) { 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(); MessageDialog md = new MessageDialog("This is a MessageDialog", "Title"); bool? result = null; md.Commands.Add( new UICommand("OK", new UICommandInvokedHandler((cmd) => result = true))); md.Commands.Add( new UICommand("Don't show this again", new UICommandInvokedHandler((cmd) => result = false))); await md.ShowAsync(); if (result == true) { // do something } else if (result == false) { // do something } }
- Merged by Rob Caplan [MSFT]Microsoft employee, Moderator Monday, April 20, 2015 11:08 PM duplicate
Monday, April 20, 2015 10:52 PM -
You'll do something essentially like you have in your previous code and as discussed at http://blogs.msdn.com/b/uk_faculty_connection/archive/2013/07/25/prompting-for-feedback-within-your-windows-phone-or-windows-8-app-game.aspx
Store a value in local (or roaming) settings to track if you should or should not show the dialog.
- Proposed as answer by Jamles HezModerator Tuesday, April 28, 2015 12:30 PM
- Marked as answer by Jamles HezModerator Wednesday, April 29, 2015 1:56 PM
Monday, April 20, 2015 11:14 PMModerator