I've been reading about a lot of people suffering from rejecting their apps as they don't have a privacy policy, I've read some friends' posts talking about it but in C#, here and here.
So, How to do it in JS?
You're supposed now to be having an application wrote using HTML/JS and running so let's skip all the basics for now.
Adding a privacy policy or making use of setting charm is as easy as one two three.
First what you need is a new page for privacy policy and I created a page control inside my project called 'privacy' containing my three files 'privacy.js', 'privacy.css' and 'privacy.html'.
Inside our new 'privacy.html' and immediately after the opening <body> tag we need to add a new <div> with the following attributes id, data-win-control, and optionally data-win-option to be finally looking like this...
<body>
<div id="priv" data-win-control="WinJS.UI.SettingsFlyout" data-win-options="{width:'wide'}">
<!-- page content goes here -->
</div>
</body>
It’s important to know your choice for id and her mine was ‘priv’ and the choice for data-win-control is ‘WinJS.UI.SettingsFlyout’ and it’s not optional what is really optional here is data-win-options and it defines the width of flyout and the content of page goes inside this div you can write a normal html and even <a href=”#”>Comando</a> will work here.
Now how to tell my application about the existence of this page?
Now, and inside your apps ‘default.js’ which is by default in ‘/js/default.js’ look for the block which determines the app states witch will be usually right before ‘app.start();’ add the following code:
app.onsettings = function (args) {
args.detail.applicationcommands = {
"priv": {
title: "Privacy Policy", href: "/privacy.html"
}
};
WinJS.UI.SettingsFlyout.populateSettings(args);
};
while app is a variable declared by default as ‘var app = WinJS.Application;’ , ‘priv’ must be the id of the immediate child of <body> element in the created page, ‘title’ is the name that will appear in settings charm which is here ‘Privacy Policy’ and ‘href’ is the newly created page which is ‘/Privacy/privacy.html’ in my case.
you can still add new pages down here like for example adding about page:
app.onsettings = function (args) {
args.detail.applicationcommands = {
"priv": {
title: "Privacy Policy", href: "/privacy.html"
},
"about": {
title: "About", href: "/about.html"
}
};
WinJS.UI.SettingsFlyout.populateSettings(args);
};
So now try it and give me a feedback, I think I’ll speak next about styling the privacy policy page.