Reputation: 1267
I'm following the (getting started with push locations guide) but am running into an error on step 6:
undefined:1 Uncaught (in promise) DOMException: Registration failed - permission denied
My manifest.json file is loading correctly based on the Network tab.
I have entered my correct project number into manifest.json. I have tried adding other settings not mentioned in the guide:
{
"name": "Push Notifications codelab",
"gcm_sender_id": "123456789",
"gcm_user_visible_only": true,
"permissions": [
"gcm"
]
}
I am running my server on localhost as per the guide.
Upvotes: 1
Views: 6683
Reputation: 121
If you're using Brave(the browser) and having the same issue, you have to enable Use Google Services for Push Messaging in the settings.
In order to enable it:
Brave settings > Privacy and Security > Use Google Services for Push Messaging
or use brave://settings/privacy
shortcut.
Upvotes: 12
Reputation: 1267
My problem was actually in my settings for Chrome. Under Content Settings, Notifications was set to Do not allow any site to show notifications. Changing this setting to Ask when a site wants to show notifications resolved the issue for me.
Upvotes: 2
Reputation: 13469
DOMException
occurs when an operation is impossible to perform, either for logical reasons, because data is lost, or because the implementation has become unstable. You got your error DOMException: Registration failed - permission denied maybe because the manifest was loaded from a different domain than the main page. Suggested from this thread, try to use <link rel="manifest" href="/manifest.json">
if your page is not located at the root of the website. You can also check on this related SO question.
Upvotes: 0