title: How to trigger notifications from my backend using Firebase?
body: <p>I'm developing push notifications for my Ionic app.
  I have a notification service in which I have:</p>
  <pre><code>// Get permission from the user
    async getToken() {
      let token;
      if (this.platform.is('android')) {
        token = await this.firebase.getToken();
      }
      if (this.platform.is('ios')) {
        await this.firebase.grantPermission();
        token = await this.firebase.getToken();
        // await this.firebaseNative.grantPermission();
      }
      console.log('Saving token ' + token + ' to Firebase and Askme');
      return this.saveTokenToFirestore(token);
    }
  
  
    // Save the token
    private saveTokenToFirestore(token: string){
      if(!token){
        return;
      }
        const devicesRef = this.firestore.collection('devices');
        if (this.licenseService.currentLicense) {
            this.configService.getStoredUsername(this.licenseService.currentLicense.referenceURL).then((username: string) =&gt; {
              const docData = {
                  token,
                  userId: username,
              };
              return  devicesRef.doc(token).set(docData);
            });
        }
    }
  
    // Listen to incoming FCM messages
    onNotifications() {
      return this.firebase.onMessageReceived();
    }
  </code></pre>
  <p>And in my app.component:</p>
  <pre><code>// Get a token
        this.notservice.getToken();
  
        this.notservice.onNotifications().pipe(
          tap(async msg =&gt; {
            const toast = await this.toastController.create({
            message: msg.body,
            duration: 5000
            });
            toast.present();
          })
        )
      .subscribe();
        });  
  </code></pre>
  <p>I'm currently getting push notifications from Firebase console, but I'd like to connect Firebase to my app server. I have a method that returns messages and it's this:</p>
  <pre><code>onMessage:(msg) =&gt; {
              this.receiveMessage(msg);
  </code></pre>
  <p>How can I link this method to my Firebase configuration in order to see this &quot;msg&quot; as a push notification?
  I practically need to trigger notifications from my backend.</p>
  <p>Thanks a lot</p>