Vishnu
Vishnu

Reputation: 475

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

Upvotes: 6

Views: 10872

Answers (1)

Chris Bartling
Chris Bartling

Reputation: 96

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.

Upvotes: 5

Related Questions