如果授予位置权限,请签入托管 Web 应用程序
Check in Hosted Web App if location permission is granted
我有一个简单的 Windows10 Web 应用程序,由 MS Appstudio https://appstudio.windows.com/ => "Hosted Web App" 生成。
该应用仅使用 "Package.appxmanifest" 并加载移动优化网站。
在 Web 应用程序中,我使用 .
是否可以集成 https://docs.microsoft.com/en-us/windows/uwp/maps-and-location/get-location 中的 "Change the location privacy settings" 函数?
<!--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>
In the Web App I use the . Is it possible to integrate the "Change the location privacy settings" function from https://docs.microsoft.com/en-us/windows/uwp/maps-and-location/get-location ?
对于您的场景,您可以通过在 html 页面中使用 java-scrip Api 来集成 "Change the location privacy settings" 功能。您可以参考以下代码启动 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 ")
}
}
})();
我有一个简单的 Windows10 Web 应用程序,由 MS Appstudio https://appstudio.windows.com/ => "Hosted Web App" 生成。 该应用仅使用 "Package.appxmanifest" 并加载移动优化网站。
在 Web 应用程序中,我使用 . 是否可以集成 https://docs.microsoft.com/en-us/windows/uwp/maps-and-location/get-location 中的 "Change the location privacy settings" 函数?
<!--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>
In the Web App I use the . Is it possible to integrate the "Change the location privacy settings" function from https://docs.microsoft.com/en-us/windows/uwp/maps-and-location/get-location ?
对于您的场景,您可以通过在 html 页面中使用 java-scrip Api 来集成 "Change the location privacy settings" 功能。您可以参考以下代码启动 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 ")
}
}
})();