Adding Privacy Statement to Windows 8 Store App Built With Monogame

October 01, 2013

This has been covered many times on the web, but when using Monogame it isn’t as straightforward (not that it’s rocket science).

The key thing is to make sure that when creating the Monogame project, it is created using Monogame and XAML (I’ve blogged about this previously here).

In App.xaml.cs, add the following function to call your privacy statement:



Private async privacyCommandInvoked(Windows.UI.Popups.IUICommand command)
{
    Uri uri = new Uri("http://mypage.com/privacystatement.htm"");
    await Launcher.LaunchUriAsync(uri);
}

As far as I’m aware, it is a requirement of the Win 8 approval process that this be a web site; that is, it can’t simply be a XAML page that displays the text.

Now create a function to add this to the menu, and an event to handle it when it’s selected:



private AddFlyouts()
{
    var settingsPane = SettingsPane.GetForCurrentView();
    settingsPane.CommandsRequested += settingsPane\_CommandsRequested;
}

void settingsPane\_CommandsRequested(Windows.UI.ApplicationSettings.SettingsPane sender, Windows.UI.ApplicationSettings.SettingsPaneCommandsRequestedEventArgs args)
{
    commandHelp = new SettingsCommand("privacy", "Privacy Policy", privacyCommandInvoked);
    args.Request.ApplicationCommands.Add(commandHelp);
}

You’ll need to change the OnLaunched event to call `AddFlyouts();` and you should be set.  

Remember that this will launch a web browser, so you may need to handle the suspend / resume events to deal with that.



Profile picture

A blog about one man's journey through code… and some pictures of the Peak District
Twitter

© Paul Michaels 2022