title: ERROR TypeError: firebase.messaging is not a function
body: <p>I'm getting error, ERROR TypeError: firebase.messaging is not a function
  Whats wrong with it ?</p>
  
  <blockquote>
  <pre><code>import { Injectable } from '@angular/core';
  import { AngularFireDatabase } from 'angularfire2/database';
  import { AngularFireAuth} from 'angularfire2/auth';
  import * as firebase from 'firebase/app';
  
  import 'rxjs/add/operator/take';
  import { BehaviorSubject} from 'rxjs/BehaviorSubject';
  
  @Injectable()
  export class MessagingService {
  
  messaging = firebase.messaging();
  currentMessage = new BehaviorSubject(null);
  
  constructor(private db: AngularFireDatabase, private afAuth: 
  AngularFireAuth) {
  }
  
  private updateToken(token) {
    this.afAuth.authState.take(1).subscribe(user =&gt; {
      if (!user) { return; }
  
      const data = { [user.uid]: token };
      this.db.object('fcmTokens/').update(data);
    });
  }
  
  getPermission() {
      this.messaging.requestPermission()
          .then(() =&gt; {
              console.log('Notification permission granted.');
              return this.messaging.getToken();
          })
          .then(token =&gt; {
              console.log(token);
              this.updateToken(token);
          })
          .catch((err) =&gt; {
              console.log('Unable to get permission to notify.', err);
          });
  } 
  
  receiveMessage() {
      this.messaging.onMessage((payload) =&gt; {
          console.log('Message received. ', payload);
          this.currentMessage.next(payload);
      });
    }
  }
  </code></pre>
  </blockquote>
  
  <p><code>ERROR TypeError: firebase.messaging is not a function
  </code>
  I'm having big probleems with that error, I don't have any idea how to fix that, please help me repair that code. I've done everything like an example, but it doesn't work. thank you so much for your answers.</p>