-
Notifications
You must be signed in to change notification settings - Fork 55
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
Notifications do not work correctly #5051
Labels
bug
Something isn't working
Comments
@brendrch could you provide repro in this sample app https://github.com/MicrosoftEdge/WebView2Samples/tree/main/SampleApps/WebView2WindowsFormsBrowser |
Hello, i am currently on holiday and will provide samples at the end of February Best regards Am 05.02.2025 um 14:51 schrieb Akhila Veerapuraju ***@***.***>:
@brendrch could you provide repro in this sample app https://github.com/MicrosoftEdge/WebView2Samples/tree/main/SampleApps/WebView2WindowsFormsBrowser
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Hello,
I have created a reproducible Sample at https://mypoi3d.com/PushTest/src/index.html (it is based on the code from https://github.com/Minishlink/web-push-php-example)
### Edge behavior:
If you open the sample URL in Edge and press the “Enable Push notifications” you will see a “Loading…” button which does no query the Notification-Permission although it is set to ask.

You must explicitly enable the Notification-Permission in the site settings.

After that you can enable the Push Notifications with the web site button and send a push notification. It is shown in the console output

### WebView2 behavior
In the WebView2WindowsFormsBrowser Sample the button shows a “Push notifications are not compatible with this browser” information.

If you explicitly allow the permissions and add an event handler for permission requests, it still does not work and you get the above-mentioned exception
```
private void WebView2Control_CoreWebView2InitializationCompleted(object sender, CoreWebView2InitializationCompletedEventArgs e)
{
if (!e.IsSuccess)
{
MessageBox.Show($"WebView2 creation failed with exception = {e.InitializationException}");
UpdateTitleWithEvent("CoreWebView2InitializationCompleted failed");
return;
}
// Setup host resource mapping for local files
this.webView2Control.CoreWebView2.SetVirtualHostNameToFolderMapping("appassets.example", "assets", CoreWebView2HostResourceAccessKind.DenyCors);
this.webView2Control.Source = new Uri(GetStartPageUri(this.webView2Control.CoreWebView2));
this.webView2Control.CoreWebView2.SourceChanged += CoreWebView2_SourceChanged;
this.webView2Control.CoreWebView2.HistoryChanged += CoreWebView2_HistoryChanged;
this.webView2Control.CoreWebView2.DocumentTitleChanged += CoreWebView2_DocumentTitleChanged;
this.webView2Control.CoreWebView2.AddWebResourceRequestedFilter("*", CoreWebView2WebResourceContext.Image, CoreWebView2WebResourceRequestSourceKinds.Document);
this.webView2Control.CoreWebView2.ProcessFailed += CoreWebView2_ProcessFailed;
this.webView2Control.CoreWebView2.FrameCreated += WebView_HandleIFrames;
UpdateTitleWithEvent("CoreWebView2InitializationCompleted succeeded");
//added !!!!!!!!!!!!!!!!!!
this.webView2Control.CoreWebView2.Profile.SetPermissionStateAsync(CoreWebView2PermissionKind.Notifications, "https://mypoi3d.com/PushTest/src/index.html", @CoreWebView2PermissionState.Allow);
this.webView2Control.CoreWebView2.PermissionRequested += WebView_PermissionRequested;
EnableButtons();
}
private void WebView_PermissionRequested(object sender, CoreWebView2PermissionRequestedEventArgs e)
{
e.State = CoreWebView2PermissionState.Allow;
}
```
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What happened?
I use Webview2 version 1.0.2957.106 with C# and load a web site over https which use push notifications.
It works correctly with Chrome, Firefox and Edge browsers but not with WebView2.
On the Javascript side the notifications are initiated by registering a service worker with
navigator.serviceWorker.register
this works correctly
The subscrition to push notifications with
causes the exception AbortError Registration failed - push service error
Before the subscription is called, a check for the permissinon is made by
if (Notification.permission === 'granted')
On the C# side there is a permission request callback which allows the notification request
I have reset all permissions to default when the page is loaded by
If the permissions are set as
e.State = CoreWebView2PermissionState.Default;
no popup asking the user for notification permission is displayed (for camera and mic permissions a popup is shown).I assume, that the allowance of the notification permission by code does not work correctly since no popup is displayed and no user interaction is requested (the Edge browser does not show a popup neither, the notification permission must be set here interactively to make the web site work)
Importance
Important. My app's user experience is significantly compromised.
Runtime Channel
Stable release (WebView2 Runtime)
Runtime Version
1.0.2957.106
SDK Version
1.0.2957.106
Framework
Winforms
Operating System
Windows 11
OS Version
26100.2894
Repro steps
Please see descritpion under "What happened".
The web site which is called is https://test.mypoi3d.com.
The notification is initiated after a login (if needed i can create one for you)
Repros in Edge Browser
No, issue does not reproduce in the corresponding Edge version
Regression
No, this never worked
Last working version (if regression)
No response
The text was updated successfully, but these errors were encountered: