2017-04-17 22 views
0

我有一個簡單的Windows10 Web應用程序,由MS Appstudio生成https://appstudio.windows.com/ =>「託管Web應用程序」。 該應用只使用「Package.appxmanifest」並加載移動優化網站。如果授予位置許可,請檢入托管的Web應用程序

在我使用的Web App中。 是否可以從https://docs.microsoft.com/en-us/windows/uwp/maps-and-location/get-location集成「更改位置隱私設置」功能?

<!--Set Visibility to Visible when access to location is denied --> 
<TextBlock x:Name="LocationDisabledMessage" FontStyle="Italic" 
       Visibility="Collapsed" Margin="0,15,0,0" TextWrapping="Wrap" > 
      <Run Text="This app is not able to access Location. Go to " /> 
       <Hyperlink NavigateUri="ms-settings:privacy-location"> 
        <Run Text="Settings" /> 
       </Hyperlink> 
      <Run Text=" to check the location privacy settings."/> 
</TextBlock> 

回答

1

在Web應用程序我使用。是否可以從https://docs.microsoft.com/en-us/windows/uwp/maps-and-location/get-location集成「更改位置隱私設置」功能?

對於您的場景,您可以通過在html頁面中使用java-scrip Api來集成「更改位置隱私設置」功能。您可以參考以下代碼來啓動privacy-location

的index.html

<!DOCTYPE html> 
<html> 
<head> 
    <meta charset="utf-8" /> 
    <title>LunchUriTest</title> 
    <link href="css/default.css" rel="stylesheet" /> 
</head> 
<body> 
    <div>Content goes here!</div> 
    <button id="btnClick">Clik Me</button> 

    <script src="js/main.js"></script> 
</body> 
</html> 

Main.js

(function() { 
    document.querySelector("#btnClick").onclick = function() { 
     if (typeof (Windows) != "undefined") { 
      var uri = Windows.Foundation.Uri("ms-settings:privacy-location") 
      Windows.System.Launcher.launchUriAsync(uri); 
     } else { 
      alert("Current environment is not uwp ") 
     } 
    } 
})(); 
相關問題