UWP (C#) - Getting result of PermissionRequest

时间:2016-04-07 10:28:18

标签: c# geolocation win-universal-app

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.

1 个答案:

答案 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.

相关问题