kv5vaa
Last Updated: February 25, 2016
·
1.167K
· danialgoodwin
Vest 500x500

Easiest Way To Add Windows 8 Privacy Policy Charm

If your Windows 8 app has declared it needs connection to the Internet, then your app MUST have a privacy policy or it WILL FAIL certification.

So, here is the fastest way to add a privacy policy. It will appear in the Charms.
1. Copy+paste one line in the page initialization.
2. Copy+paste two functions elsewhere in your app.
3. Test. Make sure you have Internet declarations on in your app manifest (it is on by default).

using Windows.UI.ApplicationSettings; 
using Windows.UI.Popups;

namespace MyProjectName
{
    public sealed partial class MainPage : Page
    {
        public MainPage()
        {
            this.InitializeComponent(); // This line should already be in your code.

            Windows.UI.ApplicationSettings.SettingsPane.GetForCurrentView().CommandsRequested += SettingCharmManager_CommandsRequested; // Add this line.
        }

        // Add the following two functions.    
        private void SettingCharmManager_CommandsRequested(Windows.UI.ApplicationSettings.SettingsPane sender, Windows.UI.ApplicationSettings.SettingsPaneCommandsRequestedEventArgs args)
        {
            args.Request.ApplicationCommands.Add(new Windows.UI.ApplicationSettings.SettingsCommand("privacypolicy", "Privacy policy", o => loadWebPage("http://simplyadvanced.net/wiki/index.php?title=Privacy_policy")));
        }

        private async void loadWebPage(string strUrl)
        {
            Uri uri = new Uri(strUrl);
            await Windows.System.Launcher.LaunchUriAsync(uri);
        }

        ...
        ...
    }
}

Note: You may want to change the URL to your own privacy policy.

Say Thanks
Respond