Adding Privacy Setting to Charm Windows 8 JavaScript Applications

Problem
Have your windows 8 app certification ever failed just because of privacy-related requirements ? While certification process Have you ever got message stating that “The app has declared access to network capabilities and no privacy statement was provided in the Windows Settings Charm.” ? If the answer is in Yes, it means your app is not fulfilling the certification requirement 4.1: “Your app must comply with the following privacy-related requirements: Your app must have a privacy statement if it is network-capable, and your app must obtain opt-in or equivalent consent to share personal information”
for more detail check there 4.1 Your app must comply with the following privacy-related requirements

Solution
It is not so complex to solve this problem. Infact You don’t need to worry about lines of coding. you can solve this issue by writing only few lines of code. First of all you need to create a new HTML file including privacy statement and the second one is implementing/Adding this HTML file to default.js file.

Lets see how can we accomplish task step by step.
Step 1 : Create a HTML file stating your Privacy Policies.
charmsetting2

<div id="privid" data-win-control="WinJS.UI.SettingsFlyout" style="background-color: black;">
This application does not share personal information with third parties nor does it store any information about you.
This privacy policy is subject to change without notice and was last updated on [INSERT DATE]. If you have any questions feel free to contact me directly at <a href="mailto:[Your EMAIL ADDRESS]">[Your EMAIL ADDRESS]</a>.
you can also mention your link for users to navigate
<a href="//www.google.co.in”">Click Me!</a>
</div>

Step 2 : Adding Privacy.html in default.js.
Charmsetting 3

Code to Implement :

app.onsettings = function (args) {
        args.detail.applicationcommands = {
            "privid": {
                title: "Privacy Policy", href: "pages/settings/privacy.html"
            }
        };
        WinJS.UI.SettingsFlyout.populateSettings(args);
    };

default.js file wile look like :

// For an introduction to the Blank template, see the following documentation:
// http://go.microsoft.com/fwlink/?LinkId=232509
(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) {
                // TODO: This application has been newly launched. Initialize
                // your application here.
            } else {
                // TODO: This application has been reactivated from suspension.
                // Restore application state here.
            }
            args.setPromise(WinJS.UI.processAll());
        }
    };

   // Code to implement Privacy policy
    app.onsettings = function (args) {
        args.detail.applicationcommands = {
            "privid": {
                title: "Privacy Policy", href: "pages/settings/privacy.html"
            }
        };
        WinJS.UI.SettingsFlyout.populateSettings(args);
    };

    app.start();
})();

you are done with all steps. now check your code to very its running well or not. Look below, here I’ve posted screenshot demo app.

Move your mouse at the right corner of screen and click on setting. you’ll get as given picture
charmsetting4

click on “privacy policy” to see privacy policies.
charmsetting5

Download SourceCode
want to download sourcecode : ClickMe!

Happy Coding 🙂

Advertisements

About Ravi Ranjan Kumar

An Indian who Living, Loving & Learning Technology with different tastes and willing to share knowledge and thoughts.
This entry was posted in CodeProject, Tips&Tricks, Windows 8 and tagged , , , , . Bookmark the permalink.

8 Responses to Adding Privacy Setting to Charm Windows 8 JavaScript Applications

  1. magrao says:

    Thank you. Helped me a lot.

  2. hola…it worked out for me..ty very much..:)

  3. Marco says:

    Thank you, this helped me.
    It is important to note that also it is a requirement to have an URL with the privacy policy to be filled in the description page.

  4. kukujaora says:

    how to add tow or more options about us and privacy …… etc

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s