Windows Store development: adding a privacy statement to the settings charm

I posted before that at first, both NeuroMind and OrthoRef did not pass certification for the Windows Store, because the so-called settings charm did not contain a privacy policy. Actually, this minor issue is one of the more frequent reasons why apps don’t pass. Silly actually… because the check which can be done from Visual Studio does not notice it, and the app templates don’t include it by default. Because it might be a copy and paste otherwise… yeah, right.

Anyway, for those who encounter the issue, here is a quick and easy solution – using JavaScript and WinJS.

First, open the default.js file, and look for this piece of code:

Now, you’ll want to add your privacy info to the menu at the app’s initialization, so add a few lines in the initialization section so that it looks like this:

Using the e.detail.applicationcommands parameter, you can add a section to the settings charm: I left the “help” name intact, as changing it to (e.g.) “privacy” did not work. However, feel free to change the title according to your wishes, and refer to an HTML file containing the actual privacy information. In my case, the privacy.html file looks like this:

And that’s it! You can invoke the app settings by pressing WinKey + I (i) on your keyboard, or swiping the right side of the screen on your tablet. You will see an option “Privacy policy” on top of the (default) “Permissions” option, and when you click it, the content from privacy.html will be displayed. You can change some CSS parameters for some additional styling, if you wish.

Good luck with the Windows Store certification process!

6 Responses to “Windows Store development: adding a privacy statement to the settings charm”

  1. Nick says:

    Thanks for posting this!

    Can I ask you to ad one extra step? I spent a few hours tonight trying to figure out why I was getting “RESOURCE_NOT_FOUND” errors while trying to do this.

    After creating the “privacy.html” file, you must left click it in the solution explorer and select “Include In Project”

    Thanks again!

  2. Thanks for the addition! I did not have this problem, because I create a new HTML file from VS and then pasted this code into it. But yes, I suppose that if you create the HTML outside VS, then you need to include it in your project (or refresh some resource maybe).

  3. Terry Thorsen says:

    Thanks man. Totally insane that this isn’t just a checkbox in the manifest, nor clearly documented by Microsoft.

  4. Terry Thorsen says:

    Here’s some derived code for default.js that allows you to create links to external websites. On my surface the id tags don’t seem to do anything, thus the “blah”.


    function createSettingsExternalLink(eventArgs, title, url) {
    function generateExternalLinkClosure(url) {
    return function (settingsCommand) {
    var uri = new Windows.Foundation.Uri(url);

    Windows.System.Launcher.launchUriAsync(uri).then(
    function (success) {
    if (success) { } // URI launched
    else { } // failed
    });
    }
    }

    var settingsCommand = new Windows.UI.ApplicationSettings.SettingsCommand("blah", title, generateExternalLinkClosure(url));
    eventArgs.request.applicationCommands.append(settingsCommand);
    }
    function onCommandsRequested(eventArgs) {
    createSettingsExternalLink(eventArgs, "ChartIQ Home Page", "http://www.chartiq.com");
    createSettingsExternalLink(eventArgs, "My Account", "http://www.chartiq.com/realtime/myaccount.html");
    createSettingsExternalLink(eventArgs, "Privacy Policy", "http://www.chartiq.com/privacy");
    }

    (function () {
    "use strict";

    WinJS.Binding.optimizeBindingReferences = true;

    var app = WinJS.Application;
    var activation = Windows.ApplicationModel.Activation;

    app.onactivated = function (args) {
    if (args.detail.kind === activation.ActivationKind.launch) {
    if (args.detail.previousExecutionState !== activation.ApplicationExecutionState.terminated) {
    var settingsPane = Windows.UI.ApplicationSettings.SettingsPane.getForCurrentView();
    settingsPane.addEventListener("commandsrequested", onCommandsRequested);
    } else {}
    args.setPromise(WinJS.UI.processAll());
    }
    };

    app.start();
    })();

  5. Panorama says:

    Thanks for posting this, the code is perfect and great instructions; I’m just starting out on Win 8 apps and this really helped push through the certification challenges, that Microsoft like to throw at us……

  6. santhosh says:

    Thank you.. it works fine…

Leave a Reply

Your email address will not be published. Required fields are marked *