Skip to content
Advertisement

Allow notifications Android webview

Context I’m trying to add push notifications that come from my website. My code:

  • MainActivity.java
JavaScript
  • AndroidManifest.xml
JavaScript
  • activity_main.xml
JavaScript

Problem
I tried code from this post but it did not help.

However, I think that I should allow notifications somewhere. I tried to open my website in a browser and it actually asks the permission while my app does not. (left: browser, right: webview)

enter image description here

Advertisement

Answer

The WebView does not support the API that websites use to show notifications, while browsers do support that API. This is why you see the notifications in the browser, but not in the WebView. See this page for the list of environments that support the notifications API.

If your WebView displays a website that you control, you may modify the website to use some other mechanism to show notifications (via some java interface).

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement