Windows : Adding privacy URL to charm settings

After more than a month of hardcore designing,coding,animating,testing etc., on my game(soccer),i thought its time to push it to Windows store.

I have done almost everything required (will write in my next post) to make it compatible with windows 8/8.1 . Then,I took this to windows app lab for a quick review.There comes my friend Ujjwal,he says you missed adding the privacy charm !!! without this it will not pass the store review.

ufff!! ok calm down…its just one small thing to achieve then started searching for some code snippets to quickly do this…

Got some….but they didn’t work…few of them were throwing errors….Then after 1 hour of (re)search…alas!!! i made it work and i could see privacy charm on the settings of my game on windows 8…..

C#/XAML

1) In your App.xaml.cs,

Add above the namespace

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

2) Add the below line to your app initialization /onLaunched event

 SettingsPane.GetForCurrentView().CommandsRequested += SettingCharmManager_CommandsRequested;

3)Add these methods to your class

[code language=”csharp”]private void SettingCharmManager_CommandsRequested(SettingsPane sender, SettingsPaneCommandsRequestedEventArgs args)
{
args.Request.ApplicationCommands.Add(new SettingsCommand("privacypolicy", "Privacy policy", OpenPrivacyPolicy));
}

private async void OpenPrivacyPolicy(IUICommand command)
{
Uri uri = new Uri("http://onestopdotnet.wordpress.com");
await Windows.System.Launcher.LaunchUriAsync(uri);
}[/code]

Sample Privacy Policy 

privacy charm

It worked like a Charm 🙂

Polyglot & Pragmatic Programmer • Developer Advocate, IBM Cloud • Intel software Innovator • DZone MVB
(Visited 4 times, 1 visits today)

You may also like...

Show Buttons
Hide Buttons