Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to request permission notification in WinForm WebView2? #1350

Closed
bhtri opened this issue Jun 3, 2021 · 1 comment
Closed

How to request permission notification in WinForm WebView2? #1350

bhtri opened this issue Jun 3, 2021 · 1 comment

Comments

@bhtri
Copy link

bhtri commented Jun 3, 2021

Hi everyone!
I want display the website to winforms application (in windows 10) through webview2, and have a look at the sample here.
But in my web, push notification permission is required, so is it possible to show a popup requesting permission like on the website? or is it possible to handle the event when permission is requested?

This is my code javascript on website

function requestPermission() {
    console.log('Requesting permission...');
    Notification.requestPermission().then((permission) => {
      if (permission === 'granted') {
        console.log('Notification permission granted.');
      } else {
        console.log('Unable to get permission to notify.');
      }
    });
  }

And error: An error occurred while retrieving token. FirebaseError: Messaging: The notification permission was not granted and blocked instead. (messaging/permission-blocked).

I searched and found CoreWebView2.PermissionRequested Event but when I implement it can't raised.

public Form1()
{
    InitializeComponent();
    Init();
    webView21.CoreWebView2.PermissionRequested += CoreWebView2_PermissionRequested;
}
private void CoreWebView2_PermissionRequested(object sender, Microsoft.Web.WebView2.Core.CoreWebView2PermissionRequestedEventArgs e)
{
    System.Console.WriteLine("Hello!!!");
}

Thank you very much

@bhtri bhtri added the question label Jun 3, 2021
@tomhoh
Copy link

tomhoh commented Jun 3, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants