How to check that native notifications are enabled for chrome? - javascript

I can block notification in chrome by set 'off' in notification settings.
And after that when I send notification with chrome.notifications.create I didn't receive any error.
I tried to check permission with chrome.notifications.getPermissionLevel and got 'granted'.
I tried to check that no one notification is appeared with chrome.notifications.getAll, but suddenly they were added, but didn't show.
There is a way to check that I can show a notification to the user?

Related

Javascript Notification show as 'pop-up'

Currently, I am working on a PWA.
I would like to implement a push notification system, luckily the browser exposes the Push API. I got this part working so far, I can receive the push event in the Service Worker.
But when displaying a notification, the notification is received 'silently' in the background.
What i wish that happened:
But this 'pop-up' style message is disabled by default when the PWA is installed (at least, I think so). The default behaviour causes the notification to only shop op in the notification tray, without ever showing above popup.
When I go the the settings of the PWA's notifications, there is an option to enable pop-up notifications: 'Show as pop-up'
When i enable this options, i get the desired result. However i wish this to be de thefault behaviour, and not have to tell every user of the web app to change the settings on their device.
My used code for the Notification from within my push event listener in the service worker.
self.registration.showNotification('New message', {
body: payload,
});
Testing on Samsung Galaxy S22 with Chrome as the (default) browser.
Does anyone know why this is the default behaviour and if there is a fix for this?
Thanks in advance

how can I force chrome browser to always accept the request of a notification permission?

I am having some difficulties with having chrome letting me request notification permission multiple times.
As you know, to make sure the user will receive the notifications my website will be prompting on screen, the browser must allow the notifications.
What I do is this :
Notification.requestPermission()
most of the times it works, and I see a dialog box proposing the user either to allow, or to block notifications.
But, if I dismiss this dialog box more than three times, then Chrome temporarily blocks the request permission for a week! (https://chromestatus.com/feature/6443143280984064)
Does anyone know anyway to bypass this ?
Simple answer, you cant. It would be a security risk.

Gmail API: python application error

https://developers.google.com/gmail/api/quickstart/python#step_1_turn_on_the_api_name
i executed python quickstart.py
and it opened browser-like window.
i've typed my email address and the password and reached a screen where i need to press "allow" button
when I did that I get this error:
"You've reached this page because we have dtected that Javascript is disabled in your browser. The age you attempted to load cannot display properly if script is disabled. Please enabled scripts and retry the opration or go back in your browser."
But im running this on a putty window.
how do i get pass this?
i had to add an option --noauth_local_webserver to python quickstart.py and it gave me the link to open on a browser to authenticate

how to make use fake ui permanent in chrome?

I have made an application to record a video by following this steps : https://github.com/muaz-khan/RecordRTC,
I want access to allow the camera always 'allow',
i've tried bypass the allow permission in popup allow webcam use start chrome --use--fake-ui--for--media-stream and it's work for me, but when i closed my chrome and then i opened chrome again , the popup permission allow webcam still showing,
what's the solution?
If you serve your application from an https domain, Chrome will remember the user's answer to the permissions dialog after the first use, so if they use it once, permission is granted (they click "allow"), the next time they use it, permission will be granted automatically and they won't be shown the pop up again.

Issue with HTML5 Notification and permission

I'm trying to use the new HTML notification API...
I'm still stuck in the request authorization phase;
when user click on a button it's executed the function:
// this is all inside a click handler
var fn = console.info;
window.Notification.requestPermission(function(grant) {
fn(grant);
});
When i tryed this for the first time in chrome, a chrome's message came out asking me if i want to concede the Notification grant to my localhost web site... I said no (just to test even this case). Then I tried again, but that message from chrome never came out.
My question:
If the user change opinion about notification, how could enable notification for a website?
Maybe do I've to change something in the chrome settings?
Thanks in advance
You can manage and re-allow notifications in Chrome by going to Settings -> Privacy -> Content Settings -> Scroll down to Notifications - here you can manage which sites are allowed to show notifications and which are not.
Update:
As mentioned by #ivan_vaz in the comments, it is also possible to configure this as well as other permissions by clicking the favicon of the website in the address/navigation bar.

Categories

Resources