0

I am trying to setup firebase messaging from laraval server to chrome extension but while setting up receiver in chrome extension service worker, I am getting following error

code: "messaging/only-available-in-window" message: "Messaging: This method is available in a Window context. (messaging/only-available-in-window)." stack: "FirebaseError: Messaging: This method is available in a Window context. (messaging/only-available-in-window).\n at t.requestPermission (chrome-extension://naidknbafhicaoafmfimlpmolidhnjno/assets/js/firebase-messaging.js:122:403)\n at chrome-extension://naidknbafhicaoafmfimlpmolidhnjno/background.js:19:15" [[Prototype]]: Error I am looking for solution from last 2 days but did not find anything. Is there any way to setup firebase messaging in chrome extension maninefst v3 or anyother alternative?

Maaz Khan
  • 21
  • 1
  • 7
  • As the error says you can't use this script in a service worker, so report the bug to FCM support or find an existing report, which should already exist. Meanwhile, open an html file of your extension in a new window/tab (or an [extension iframe](/a/25100953) in a web page) and use FCM there. – wOxxOm Apr 06 '22 at 06:25
  • but how I will be able to receive messages after window is closed? – Maaz Khan Apr 06 '22 at 06:55
  • ManifestV3 is great, isn't it? You'll have to keep the window open. – wOxxOm Apr 06 '22 at 07:29
  • ok thanks can you help me with one more thing messaging.requestPermission is not a function with v9 sdk what should i do with it? – Maaz Khan Apr 06 '22 at 07:55
  • I don't know, try asking in that thread. – wOxxOm Apr 06 '22 at 07:58

0 Answers0