Firebase Messaging - Failed to execute 'atob' on 'Window'
Unable to run initial page: Uncaught DOMException: Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded. at B (http://localhost:8081//firebase/4.10.0/firebase-messaging.js:6:19408) at t.usePublicVapidKey (http://localhost:8081//firebase/4.10.0/firebase-messaging.js:6:21452) at http://localhost:8081/:89:13
I have same problem
I also have the same issue
Same for me. Appears in console on fresh master code, just run firebase serve -p 8081, also when used firebase use --add first. Both on Firefox and Chrome.
EDIT:
Looks like branch implicit-init-messaging worked for me :)
@domints
I have this same issue, can you please elaborate more what is exactly the source of the issue and what does implicit-init-messaging do?
Totally right - I've made a small PR to fix it.
Essentially - calling getToken() in the service worker will cause a code path to be hit that is expecting the window to exist when it doesn't in a service worker.
I get last version from master and it still happens.
I don't think this issue is fixed and patched to the master branch. However, if I select implicit-init-messaging branch everything seems to work. could someone in Google merge this in master branch?
Just change the branch to implicit-init-messaging. Everything works fine in that branch
git checkout implicit-init-messaging did the trick
This problem still exists on the master at 2019/2/13.
I think this issue should not be closed? Still exists on master
Problem still exist any workarround?
I have the same error and what the fix I found was that in messaging.usePublicVapidKey('PAIR KEY') i was using the server key and it needs the "pair key". You could find that info in https://console.firebase.google.com/project/_/settings/cloudmessaging/
So the value of that function is the pair key in the console, i was confused and put the server key :man_facepalming: and that create the bug of Uncaught DOMException: Failed to execute 'atob' on 'Window':.
I was using Firebase for web, script version: https://www.gstatic.com/firebasejs/5.9.3/firebase.js And I was following this tutotorial: https://firebase.google.com/docs/cloud-messaging/js/client
Related: https://github.com/firebase/quickstart-js/issues/250
In my case, I was using an invalid key as the PublicVapidKey (an adittional space was present at the end of the string). Fixing this solved the problem
I resolved same issue by fixing the PublicVapidKey
Change to branch implicit-init-messaging worked for me!
Change to branch
implicit-init-messagingworked for me!
This worked for me 👍
In my case, I'd set the vapidKey as an .env variable and I incorrectly set vapidKey by not including process.env prefix.
I resolved the same issue by fixing the Vapid Key:
return getToken(messaging, {
vapidKey: "use-a-correct-vapidKey",
})