代码改变世界

Windows 8 添加隐私策略(C++版)

2013-02-19 20:13  chenkai  阅读(1786)  评论(6编辑  收藏  举报

well.新年上班第一天.不幸收到MS官方针对我们Snack Cards应用程序被打回消息.看看Report 内容如下:

The app has declared access to network capabilities and no privacy statement was provided in the Windows Settings Charm

如上文.Windows 8应用程序中一旦使用网络连接则对应应用程序中需要对用户说明隐私策略.其实这让封装功能透明化一种方式.有必要让用户知道隐私一些细节.这其实也是通用一种方式.App Store更像一个平台.同时这也是MS一份"免责声明".但它打开的方式是放置在Windows 8 设置界面中.所以大部分用户大多很少打开.东西虽小.但又或不可缺.这无疑也透漏一种开发商和最终用户之间的"契约精神".

其实针对隐私策略Privacy Policy 问题官方已经说得很明确如下:

4.1.1 Your app must have a privacy statement if it is network-capable

If your app has the technical ability to transmit data, you must maintain a privacy policy. You must provide access to your privacy policy in the Description page of your app, as well as in the app’s settings as displayed in the Windows Settings charm.

App capability declarations that make your app network-capable include: internetClient, internetClientServer and privateNetworkClientServer.

Your privacy policy must inform users of the personal information transmitted by your app and how that information is used, stored, secured and disclosed, and describe the controls that users have over the use and sharing of their information, how they may access their information, and it must comply with applicable laws and regulations.

详见:Windows 8 app certification requirements[windows]

在MS论坛上看到有人吐槽这个问题.其实问题很简单.因为应用程序一旦使用到了网络.其实在技术上有了实现传输用户敏感隐私数据的条件.针对这点微软官方必须强制维护一个隐私策略.其实就是一个网址.必须在你的应用的“描述”页中以及在显示于 Windows“设置”超级按钮中的应用设置中提供对你的隐私策略的访问途径.

看到很多应用隐私策略做的很粗糙.其实官方要求隐私策略必须告知用户你的应用传输的个人信息及如何使用、存储、保护和透露该信息,并且描述用户对使用和共享其信息.所具有的控制权以及他们访问其信息的方式,并且隐私策略符合适用的法律和法规.一个完整的隐私策略需要包含哪些内容[标准如下]
 
Include Infor:
 
A:what information do we collect?
B:What do we use your information for?
C:How do we protect your information?
D:Do we use cookies?
E:Do we disclose any information to outside parties?
F:Contacting Us [Info]
或是可以参考我们制作一个隐私参考版[Snack Studio Privacy Policy Document].页面有点粗糙.但内容较为完整规范.
说道这如何向Windows 8 应用程序添加隐私策略?
普遍方式在OnWindowsCreated事件中实现对隐私策略内容的添加[C#代码]:
   1:  protected override void OnWindowCreated(WindowCreatedEventArgs args)
   2:  {
   3:         SettingsPane.GetForCurrentView().CommandsRequested += PrivacyCommandsRequested;           
   4:         base.OnWindowCreated(args);
   5:   }

处理CommandRequested事件处理函数:

   1:   void PrivacyCommandsRequested(SettingsPane settingsPane, SettingsPaneCommandsRequestedEventArgs eventArgs)
   2:      {
   4:          UICommandInvokedHandler eventHandler = new UICommandInvokedHandler(onSettingsCommand);
   5:          SettingsCommand privacyStatement = new SettingsCommand("SnackCardsPrivacy", "Privacy Policy", handler);
   6:          eventArgs.Request.ApplicationCommands.Add(privacyStatement);                    
   7:      }

当用户点击Privacy Policy 时调用如下代码. 打开对应Url地址:

   1:  async void onSettingsCommand(IUICommand command)
   2:   {
   3:       if (command.Id.ToString() == "SnackCardsPrivacy")
   4:           await Windows.System.Launcher.LaunchUriAsync( new Uri("http://www.snack-studio.com/privacy.html"));
   5:   }

当用户操作点击隐私策略调用Launcher加载对应的Url地址.把网页内容显示在SettingPanel中.就是这么简单.但是如果在Xaml和Direct X混合应用程序.按照同样的思路来做的话.为了保证应用OnLaunch时间不超过5秒.推荐在应用程序中加载尽量减少操作.而是把这些操作放在MainPage 的OnLoaded或是OnNavigateTo事件中来加载.C++代码需要添加如下额外引用:

   1:  using namespace Windows::UI::ApplicationSettings;
   2:  using namespace Windows::UI::Popups;

在文件中声明操作事件如下:

   1:      public:
   2:          DirectXPage();        
   3:   
   4:          void SaveInternalState(Windows::Foundation::Collections::IPropertySet^ state);
   5:          void LoadInternalState(Windows::Foundation::Collections::IPropertySet^ state);
   6:          //Add  Privacy Policy
   7:          virtual void OnNavigatedTo(Windows::UI::Xaml::Navigation::NavigationEventArgs^ e) override;
   8:   
   9:      private:
  10:          void OnRendering(Object^ sender, Object^ args);
  11:          void PageLoaded(Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ args);
  12:   
  13:          //Add  Privacy Policy
  14:          void AddPrivacySetting(Windows::UI::ApplicationSettings::SettingsPane^ sender, Windows::UI::ApplicationSettings::SettingsPaneCommandsRequestedEventArgs^ args);
  15:          void AddBtnPrivacy(Windows::UI::ApplicationSettings::SettingsPaneCommandsRequestedEventArgs^ args);
  16:          void BtnPrivacyOnClicked(Windows::UI::Popups::IUICommand^ command);

在OnNavigatedTo事件作如下调用:

   1:  void DirectXPage::OnNavigatedTo(NavigationEventArgs^ args)
   2:  {   
   3:      SettingsPane::GetForCurrentView()->CommandsRequested += ref new TypedEventHandler<SettingsPane^, SettingsPaneCommandsRequestedEventArgs^>(this, &DirectXPage::AddPrivacySetting);
   4:  }

对应回调方法是AddPrivacySetting方法:

   1:  void DirectXPage::AddPrivacySetting(SettingsPane^ sender, SettingsPaneCommandsRequestedEventArgs^ args)
   2:  {
   3:      this->AddBtnPrivacy(args);
   4:  }
   5:   
   6:  void DirectXPage::AddBtnPrivacy(SettingsPaneCommandsRequestedEventArgs^ args)
   7:  {
   8:      UICommandInvokedHandler^ handler = ref new UICommandInvokedHandler(this, &DirectXPage::BtnPrivacyOnClicked); 
   9:      args->Request->ApplicationCommands->Clear();
  10:      SettingsCommand^ privacyPref = ref new SettingsCommand("CardPrivacyStament", "Privacy Policy", handler); 
  11:      args->Request->ApplicationCommands->Append(privacyPref);
  12:  }
  13:   
  14:  void DirectXPage::BtnPrivacyOnClicked(Windows::UI::Popups::IUICommand^ command)
  15:  {
  16:      using namespace Windows::Foundation; 
  17:      if(command->Id->ToString()=="CardPrivacyStament")
  18:      {
  19:         Windows::System::Launcher::LaunchUriAsync(ref new Uri("http://www.snack-studio.com/privacy.html"));
  20:      }
  21:  }

也很简单.把C#逻辑改成C++版本.

参考资料:

Windows 8 app certification document [Windows 8]

Windows 8 Certification and add Privacy Policy

无觅相关文章插件,快速提升流量