Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

importScripts is not defined firebase in angular app

in firebase-messaging-sw.js

importScripts('https://www.gstatic.com/firebasejs/3.5.2/firebase-app.js'); importScripts('https://www.gstatic.com/firebasejs/3.5.2/firebase-messaging.js

getting error as "importScripts is not defined"

where to include firebase-messaging-sw.js Js file in angular app ? I have included in scripts/firebase-messaging-sw.js .

In index.html

        <script src="scripts/firebase-messaging.js"></sc
like image 886
Vishnu Avatar asked Oct 18 '22 16:10

Vishnu


1 Answers

In your index.html, shouldn't you be referencing firebase-messaging-sw.js and not firebase-message.js? Also, I believe firebase-messaging-sw.js needs to be at the root level (no nesting in script directory). Thus you would have something like the following in index.html...

<script src="firebase-messaging-sw.js">

The service worker script will be loaded and will then import the Firebase scripts from the Firebase CDN.

like image 114
Chris Bartling Avatar answered Oct 21 '22 01:10

Chris Bartling