quickstart-js icon indicating copy to clipboard operation
quickstart-js copied to clipboard

Firebase Messaging - Failed to execute 'atob' on 'Window'

Open Max-Lev opened this issue 8 years ago • 18 comments

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

Max-Lev avatar Feb 22 '18 13:02 Max-Lev

I have same problem

wapgear avatar Mar 05 '18 15:03 wapgear

I also have the same issue

ngvenks avatar Mar 08 '18 10:03 ngvenks

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 avatar Mar 14 '18 15:03 domints

@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?

chadiczc avatar Apr 15 '18 07:04 chadiczc

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.

gauntface avatar Apr 24 '18 19:04 gauntface

I get last version from master and it still happens.

akajdan avatar May 03 '18 13:05 akajdan

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?

asimkco avatar Jul 12 '18 07:07 asimkco

Just change the branch to implicit-init-messaging. Everything works fine in that branch git checkout implicit-init-messaging did the trick

madusankapremaratne avatar Aug 10 '18 04:08 madusankapremaratne

This problem still exists on the master at 2019/2/13.

lnkusuin avatar Feb 13 '19 04:02 lnkusuin

I think this issue should not be closed? Still exists on master

ng-chicago avatar Mar 13 '19 14:03 ng-chicago

Problem still exist any workarround?

cinosh07 avatar Mar 15 '19 19:03 cinosh07

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

renzit avatar Apr 10 '19 03:04 renzit

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

marlonvidal avatar Apr 30 '20 21:04 marlonvidal

I resolved same issue by fixing the PublicVapidKey

tokuhara-hikaru avatar Sep 20 '20 06:09 tokuhara-hikaru

Change to branch implicit-init-messaging worked for me!

xielianghai avatar Nov 19 '20 07:11 xielianghai

Change to branch implicit-init-messaging worked for me!

This worked for me 👍

TotomiEcio avatar Sep 09 '21 18:09 TotomiEcio

In my case, I'd set the vapidKey as an .env variable and I incorrectly set vapidKey by not including process.env prefix.

munnayi avatar Dec 28 '22 22:12 munnayi

I resolved the same issue by fixing the Vapid Key:

return getToken(messaging, { vapidKey: "use-a-correct-vapidKey", })

iuriebury avatar May 31 '23 18:05 iuriebury