title: firebase.messaging is not a function in Angular 9
body: <p>I followed line by line this tutorial:
  <a href="https://medium.com/mighty-ghost-hack/angular-8-firebase-cloud-messaging-push-notifications-cc80d9b36f82" rel="nofollow noreferrer">https://medium.com/mighty-ghost-hack/angular-8-firebase-cloud-messaging-push-notifications-cc80d9b36f82</a></p>
  <p>How to simply put a notification web to my Angular 9 project, in my Angular CLI i put:</p>
  <pre><code>    &quot;assets&quot;: [
        &quot;src/favicon.ico&quot;,
        &quot;src/assets&quot;,
        &quot;src/firebase-messaging-sw.js&quot;,
        &quot;src/manifest.json&quot;
      ],
  </code></pre>
  <p>This is my firebase-messagin-sw.js</p>
  <pre><code>importScripts('https://www.gstatic.com/firebasejs/7.6.0/firebase-app.js');
  importScripts('https://www.gstatic.com/firebasejs/7.6.0/firebase-analytics.js');
  
  firebase.initializeApp({
    apiKey: ******************,
    authDomain: ******************,
    databaseURL: ******************,
    projectId: ******************,
    storageBucket: ******************,
    messagingSenderId: ******************,
    appId: ******************,
    measurementId: ******************
  });
  console.log(firebase);
  const messaging = firebase.messaging();
  </code></pre>
  <p>This file is in my root project and my Notification Service I create this:</p>
  <pre><code>import { Injectable } from '@angular/core';
  import { AngularFireMessaging } from '@angular/fire/messaging';
  import { BehaviorSubject } from 'rxjs';
  
  
  @Injectable()
  export class NotificationService {
  
    currentMessage = new BehaviorSubject(null);
  
    constructor(private angularFireMessaging: AngularFireMessaging) {
      this.angularFireMessaging.messaging.subscribe((_messaging) =&gt; {
        _messaging.onMessage = _messaging.onMessage.bind(_messaging);
        _messaging.onTokenRefresh = _messaging.onTokenRefresh.bind(_messaging);
      });
    }
    requestPermission() {
      this.angularFireMessaging.requestToken.subscribe(
        (token) =&gt; {
          console.log(token);
        },
        (err) =&gt; {
          console.error('Unable to get permission to notify.', err);
        }
      );
    }
    receiveMessage() {
      this.angularFireMessaging.messages.subscribe((payload) =&gt; {
        console.log('new message received. ', payload);
        this.currentMessage.next(payload);
      });
    }
  }
  </code></pre>
  <p>When my application is loaded I get this error: <strong>Uncaught TypeError: firebase.messaging is not a function</strong>, like the Angular CLI not loaded the js file but when I use this console.log(firebase) it gives to me a javascript object that doesn't have this function and after this error:</p>
  <p>I get this another error : <strong>TypeError: Failed to update a ServiceWorker for scope ('http://localhost:4200/firebase-cloud-messaging-push-scope')</strong></p>
  <p>What I'm doing wrong?</p>