how can I check if user allows or not the PermissionRequest for my WebView which needs to use user's position. The line with my message dialog isn't reached after user click "Deny".
private async void webView_PermissionRequested(WebView sender, WebViewPermissionRequestedEventArgs args)
{
if (args.PermissionRequest.PermissionType == WebViewPermissionType.Geolocation)
args.PermissionRequest.Allow();
else
await new MessageDialog("Geolocation services must be allowed for this app. Please check your settings.").ShowAsync();
}
Thank you.
答案 0 :(得分:2)
You have to check the WebViewPermissionRequest.State
to determine that user have grant the permission or not. Use args.State
.
this line
if (args.PermissionRequest.PermissionType == WebViewPermissionType.Geolocation)
only check the type of the requested permission. It have nothing to do with if user granted the permission before or not.