I have a Google Chrome Packaged App and uses a webview tag to load a remote page (that I don't control). That remote page is trying to request notification privileges and that permissions request doesn't seem to be bubbling up through to the wrapping Chrome App.
I'm using the following (overly permissive) code to allow all permission requests from the webview (and echo all console output):
webview.addEventListener('permissionrequest', function(e) {
console.log("webview requested " + e.permission);
e.request.allow();
});
webview.addEventListener('consolemessage', function(e) {
console.log('From webview: ', e.message);
});
I can't find confirmation online, but I'm thinking notification permissions are not yet allowed in webviews. If we assume that is the case, are there any other ways to potentially force notification permission for the webview'ed site that won't be blocked by CORS?
You are correct (as far as the docs go) that notification permission requests don't exist, nor there is any event to indicate that a notification wants to be shown.
What you could conceivably do is to inject a content script that will, in turn, inject a page-level script that replaces the Notification
object with something that passes a message to your content script, which relays it to your app, which can show the notification using chrome.notifications
. Here's an answer that explains this injection in more detail.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With