none
Very simple code to add Privacy URL link to Windows Charm settings - Using C#/XAML

    Question

  • Hi, my app has been rejected 3 times already. In this 3rd time at least I got some pointer on what to do:

    "Our reviewer could not find a privacy statement in the Windows Charm settings of this app"

    My app uses internet, and *does not* use the charm bar at all right now.

    I already a web page that describes the privacy policy settings.

    I am looking for the simplest possible code that adds a privacy link to the Windows Charm settings, and that privacy link opens a web page or displays text (whatever is easier). . I need the simplest way to comply with this requirement.

    Could you point me to a very simple C#/XAML example I could use? everything I find is too complex.

    Thank you very much for any help!

    -B


    el_ber

    Monday, October 08, 2012 11:30 PM

Answers

  • DAVE, THANK YOU VERY MUCH!

    Thanks for the code, this pointed me to the right direction. For anyone else having this issue, here is the code that I used:

    1) Add the namespaces

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

    2) Add the handler during app initialization

    SettingsPane.GetForCurrentView().CommandsRequested += SettingCharmManager_CommandsRequested;

    3) Add my handler that shows the privacy text

    private void SettingCharmManager_CommandsRequested(SettingsPane sender, SettingsPaneCommandsRequestedEventArgs args)
            {
                args.Request.ApplicationCommands.Add(new SettingsCommand("privacypolicy", "Privacy policy", o => LoadWebPage("http://(mylink)")));
            }

    -B


    el_ber

    • Marked as answer by el_ber Tuesday, October 09, 2012 12:33 AM
    Tuesday, October 09, 2012 12:33 AM

All replies

  •  public SettingCharmManager()
            {
                SettingsPane.GetForCurrentView().CommandsRequested += SettingCharmManager_CommandsRequested;
            }
    
            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("<url to your privacy policy>");
                await Launcher.LaunchUriAsync(uri);
            }

    Monday, October 08, 2012 11:36 PM
  • DAVE, THANK YOU VERY MUCH!

    Thanks for the code, this pointed me to the right direction. For anyone else having this issue, here is the code that I used:

    1) Add the namespaces

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

    2) Add the handler during app initialization

    SettingsPane.GetForCurrentView().CommandsRequested += SettingCharmManager_CommandsRequested;

    3) Add my handler that shows the privacy text

    private void SettingCharmManager_CommandsRequested(SettingsPane sender, SettingsPaneCommandsRequestedEventArgs args)
            {
                args.Request.ApplicationCommands.Add(new SettingsCommand("privacypolicy", "Privacy policy", o => LoadWebPage("http://(mylink)")));
            }

    -B


    el_ber

    • Marked as answer by el_ber Tuesday, October 09, 2012 12:33 AM
    Tuesday, October 09, 2012 12:33 AM
  • it is throwing an error named settingcharmmanager method must have a  return type....

    please send me the solution sir!!!!!

    Wednesday, October 10, 2012 3:18 PM
  • Try putting void as return type


    n.Wright

    Wednesday, October 10, 2012 11:48 PM
  • yah the code works but i cant find any difference between before & after applying the code...

    can u please tell me in brief where i can get the changes affected after the code is implemented and about the charm settings????

    thanks in advance!!!!!!

    Thursday, October 11, 2012 1:56 PM
  • How can we present the privacy policy ,if i don't have any privacy url.

    Can i show the privancy statement text on charm settings or another page with the privacy notes need to be added?

    How can i do that?

    Please direct me to the right solution,as am a newbie to the metro app.

    Thanks in advance.

    shrf


    Friday, October 12, 2012 11:49 AM
  • The exact code mentioned above did not work spot on for me. Below is my modification that I implemented into my app. Hope it helps somebody with the same problem! 
    //Do the following in your App.xaml.cs:
    
    //1) Add the namespaces
    
    using Windows.UI.ApplicationSettings; 
    using Windows.UI.Popups;
    
    //2) Add the handler during app initialization
    
    SettingsPane.GetForCurrentView().CommandsRequested += SettingCharmManager_CommandsRequested;
    
    //3) Add my handler that shows the privacy text
    
    private void SettingCharmManager_CommandsRequested(SettingsPane sender, SettingsPaneCommandsRequestedEventArgs args)
            {
                args.Request.ApplicationCommands.Add(new SettingsCommand("privacypolicy", "Privacy policy", OpenPrivacyPolicy));
            }
    
    
    //4) Add OpenPrivacyPolicy method
    
    private async void OpenPrivacyPolicy(IUICommand command)
            {
                Uri uri = new Uri("<insert web url to your privacy policy here>");
                await Windows.System.Launcher.LaunchUriAsync(uri);
            }
    
    
    

    • Proposed as answer by svrkarthik Sunday, October 21, 2012 12:54 PM
    Sunday, October 14, 2012 4:11 AM
  • You can make your own privacy URL via a free web hosting service such as Google pages. Just create a free webpage that has your policy on it then put the URL of that page into your code.
    Sunday, October 14, 2012 4:31 AM
  • Press Windows-Key+C, then click settings and you should see a "Privacy policy" option.
    Sunday, October 14, 2012 4:32 AM
  • See my code snippet below if you are still having trouble. I had to modify the code in el_ber's answer to get it to work.
    Sunday, October 14, 2012 4:32 AM
  • Thanks DerekM92 , I was totally confused when I had to add the privacy policy to the settings charm.

    I implemented your idea in VB and it worked like a charm :)

    Sunday, October 21, 2012 12:56 PM
  • svrkarhik: Can you please share / show the VB code you build for this?
    Wednesday, October 24, 2012 11:26 AM
  • VB Code:

    Imports Windows.UI.ApplicationSettings
    Imports Windows.UI.Popups
    
    Private Sub AddPrivacyPolicyLinkToSettingsCharm
    
        AddHandler SettingsPane.GetForCurrentView.CommandsRequested, Sub(sender, e) e.Request.ApplicationCommands.Add(New SettingsCommand("privacypolicy", "Privacy Policy", Sub() LaunchWebPage(New System.Uri("http://www.example.com/privacy-policy"))))
    
    End Sub
    
    Public Async Sub LaunchWebPage(ByVal Uri As System.Uri)
        Await Windows.System.Launcher.LaunchUriAsync(Uri)
    End Sub

    Just tested it myself and all works well! One of my apps just failed certification because of this, so I'm happy I found a solution quickly to get them pushed up for recertification!
    Friday, October 26, 2012 1:10 PM
  • Hi All,

    I would like to Thank all of you. It helped me to resolve the issue, now I have resubmitted my app to store. Waiting for result. Thanks again.

    Thursday, November 22, 2012 8:05 PM
  • You guys are awesome.  Is there a command that we can have that shows a popup online liner like the old MSGBOX command in lieu of launching a web site?
    Saturday, December 01, 2012 6:05 AM
  • I also had the same need and I used you code. Had to put void for SettingCharmManager().

    The Problem is that it still give the following exception.

    Element not found. (Exception from HRESULT: 0x80070490)

    at the code line

    SettingsPane.GetForCurrentView().CommandsRequested += SettingCharmManager_CommandsRequested;

    Please help me on this.

    Tuesday, December 11, 2012 2:24 AM
  • Hey were you able to solve your Exception problem. I 'm also having this exact same issue.

    Thanks.


    Tishawn Fahie

    Wednesday, December 26, 2012 5:02 PM
  • I figured it out thanks.

    Initialized in the wrong method.


    Tishawn Fahie

    Wednesday, December 26, 2012 5:46 PM
  • Which is the correct function for App Initialization? Is it App() constructor?
    Saturday, December 29, 2012 3:29 AM
  • I got it! Add the event handle in your main page which is referred by App.xaml.
    Saturday, December 29, 2012 7:21 AM
  • Excuse me; what do you mean? :)
    Saturday, January 12, 2013 7:31 PM
  • Hi

    This VB code does not work. Could you please check it and amend your entry.

    Friday, April 19, 2013 12:13 PM
  • This part of code :

    AddHandler SettingsPane.GetForCurrentView.CommandsRequested, Sub(sender, e) e.Request.ApplicationCommands.Add(New SettingsCommand("privacypolicy", "Privacy Policy", Sub() LaunchWebPage(New System.Uri("http://www.example.com/privacy-policy"))))

    You have give to this part App.xaml.vb:

    Protected Overrides Async Sub OnLaunched(args As LaunchActivatedEventArgs)

    Monday, June 03, 2013 12:17 PM
  • A link to an external site is not required.  You could add a -Privacy Statement- option directly to the Charms for your application and add the appropriate text there. 

    Monday, June 03, 2013 2:35 PM
  • can you  tell how did u initialize this code  SettingsPane.GetForCurrentView().CommandsRequested

    +=SettingCharmManager_CommandsRequested;



    Tuesday, June 18, 2013 2:13 PM
  • in the onlaunch method of your app.xaml.cs?

    Microsoft Certified Solutions Developer - Windows Store Apps Using C#

    Tuesday, June 18, 2013 2:24 PM
  • I have got the same problem .Did u solve your problem if yes can you tell how to over come from that.
    Tuesday, June 18, 2013 2:25 PM
  • Where to put this code exactly?

    Shadi Ayman Egyptian IGCSE student MS-DOS & VB programmer

    Wednesday, July 10, 2013 4:50 PM
  • This looks great, but where do I insert this code?  In App.xaml.vb ?
    Sunday, August 04, 2013 3:14 PM
  • SIMPLE, EASY DIRECTIONS FOR VISUAL BASIC -- PRIVACY STATEMENT AND CHARMS

    Hello Everybody, I am an activist for simple, clear, easy, step-by-step directions. Although the answer can be found above by looking for clues like in The Da Vinci Code, I will summarize them so that you do not have to go through the time and stress that I went through. Here it is in simple steps:

    (1) You will put your code in the first page of your app. This will be titled, MainPage, by Visual Studio even though you probably gave it a different name. Go to your first page, open the .xaml.vb file, and look at the top. This page should begin with "Public NotInheritable Class MainPage."

    (2) At the very, very top of this page, copy and paste this code:

    Imports Windows.UI.ApplicationSettings

    Imports Windows.UI.Popups

    (3) TonyGulino (2013) submitted this wonderful VB code to this forum:

    Private Sub AddPrivacyPolicyLinkToSettingsCharm()

    AddHandler SettingsPane.GetForCurrentView.CommandsRequested, Sub(sender, e) e.Request.ApplicationCommands.Add(New SettingsCommand("privacypolicy", "Privacy Policy", Sub() LaunchWebPage(New System.Uri("http://YourOwnWebsite.com/Privacy.html"))))

    End Sub

    Public Async Sub LaunchWebPage(ByVal Uri As System.Uri)

    Await Windows.System.Launcher.LaunchUriAsync(Uri)

    End Sub

    Cut and paste this code as your first and second subroutine within the Public NotInheritable Class MainPage class.

    (4) Your third subroutine should automatically exist and be called, "OnNavigateTo()" Place this subroutine call within the OnNavigateTo() subroutine:

    AddPrivacyPolicyLinkToSettingsCharm()

    (5) Okay, now run your app. Like DerekM92 clearly states, you press the Windows-Key and C at the same time and the charms appear on the right. (The charms are the five icons that appear.) Click the bottom charm labeled, "Settings." If you inserted the code correctly, there is now a Privacy Statement. Click it to see that it works.

    (6) If you are happy with the result, please give me a vote and post a nice message. Don't forget to share the love with TonyGulino and DerekM92. And, hey, check out my new app, CrinkleSpot, in the Windows Store under games. - David

    Wednesday, August 07, 2013 3:19 AM
  • Awesome, thanks for saving me the time and stress.

    david@calmhey.com

    Thursday, August 08, 2013 5:54 AM
  • Wow, You just made my life easy after my app failed in the store twice!

    you can add that it should be added on the on launch method:-

    protectedoverridevoidOnLaunched(LaunchActivatedEventArgsargs)

    {

    //2) Add the handler during app initialization

    SettingsPane.GetForCurrentView().CommandsRequested += SettingCharmManager_CommandsRequested;

    }

    Thursday, December 19, 2013 12:03 PM
  • The exact code mentioned above did not work spot on for me. Below is my modification that I implemented into my app. Hope it helps somebody with the same problem! 
    //Do the following in your App.xaml.cs:
    
    //1) Add the namespaces
    
    using Windows.UI.ApplicationSettings; 
    using Windows.UI.Popups;
    
    //2) Add the handler during app initialization
    
    SettingsPane.GetForCurrentView().CommandsRequested += SettingCharmManager_CommandsRequested;
    
    //3) Add my handler that shows the privacy text
    
    private void SettingCharmManager_CommandsRequested(SettingsPane sender, SettingsPaneCommandsRequestedEventArgs args)
            {
                args.Request.ApplicationCommands.Add(new SettingsCommand("privacypolicy", "Privacy policy", OpenPrivacyPolicy));
            }
    
    
    //4) Add OpenPrivacyPolicy method
    
    private async void OpenPrivacyPolicy(IUICommand command)
            {
                Uri uri = new Uri("<insert web url to your privacy policy here>");
                await Windows.System.Launcher.LaunchUriAsync(uri);
            }
    
    
    

    Thanks DerekM92!!!!!

    I also initialized in OnLaunched with no issue, but this saved me loads of time.

    Thanks again!!

    Monday, March 31, 2014 2:55 PM