A simple way of adding Privacy Policy to your WinRT application

Tags: .NET, C#, WinRT, Windows 8

Categories: .NET, WinRT

Tags: .NET, C#, Metro, Windows 8, WinRT

Every WinRT application should have a Privacy Policy otherwise you will fail the Store certification. You put the Privacy Policy in Charms, Settings. At the moment of writing this article there isn’t any component which can handle this for you property. All the components I’ve tried don’t work well, either because they haven’t been updated from Windows RC to RTM or just have some issues.

If you finally finished your app and are rushing to submit it for certification and don’t want to spend time to implement your Privacy Policy the easiest way is to create a web page with Privacy Policy and link it from your application.

In MainPage constructor (or you first page to load) add the following:

 

SettingsPane.GetForCurrentView().CommandsRequested += MainPage_CommandsRequested;

Next we need a method handler:

private  void MainPage_CommandsRequested(SettingsPane sender, SettingsPaneCommandsRequestedEventArgs args)
{
    var cmd = new SettingsCommand("PrivacyPolicy", "Privacy Policy", new Windows.UI.Popups.UICommandInvokedHandler(x =>
    {
         ShowSettingPanel();
    }));

    args.Request.ApplicationCommands.Clear();
    args.Request.ApplicationCommands.Add(cmd);
}

and the method to run the web page with your Privacy Policy:

private void ShowSettingPanel()
{
    Uri uri = new Uri("http://www.mywinrtapp.com/privacypolicy.html");
    Windows.System.Launcher.LaunchUriAsync(uri);
}

Now when you click on the Charms and Privacy Policy Internet Explorer will open the web page you specified in ShowSettingPanel.

NOTE: Don’t forget to add this link in Windows Store Details page when you submit your application otherwise you will fail the certification

Comments

comments powered by Disqus