title: FireBase push notification using cordova
body: <p>I am trying to implement Firbase push notification using cordova. I use the code for the latest fcm plug in specificaion from here : <a href="https://www.npmjs.com/package/cordova-plugin-fcm" rel="nofollow">Cordova Push Plugin</a></p>
  
  <p>I can get the register token. Then I tried to send notification from Firebase test notification module using that token. Each time I run the app in my device  I am having the alert-</p>
  
  <p>"Msg: onNotification callback successfully registered: OK"</p>
  
  <p>it is inside the second function of FCMPlugin.onNotification event.</p>
  
  <p>But the first function [where I want to get the notification]  is not called.
  I don't find where I am making mistake. Here is my code inside onDeviceReady:</p>
  
  <pre><code>function onDeviceReady() {
      // Handle the Cordova pause and resume events
      document.addEventListener( 'pause', onPause.bind( this ), false );
      document.addEventListener( 'resume', onResume.bind( this ), false );
  
      // TODO: Cordova has been loaded. Perform any initialization that requires Cordova here.
      var parentElement = document.getElementById('deviceready');
      var listeningElement = parentElement.querySelector('.listening');
      var receivedElement = parentElement.querySelector('.received');
      listeningElement.setAttribute('style', 'display:none;');
      receivedElement.setAttribute('style', 'display:block;');
  
      //=========================
      FCMPlugin.getToken(
        function (token) {
            alert("Token: " + token);
                cordova.plugins.email.open({
                    to: 'sharif@nascenia.com',
                    subject: 'Greetings',
                    body: token
                });
        },
        function (err) {
            alert("Error: " + 'error retrieving token: ' + err);
        }
      );
  
      FCMPlugin.onNotification(
        function (data) {
            alert("Notify: " + JSON.stringify(data));
            if (data.wasTapped) {
                //Notification was received on device tray and tapped by the user. 
                alert("Wrapped Notify: " + JSON.stringify(data));
            } else {
                //Notification was received in foreground. Maybe the user needs to be notified. 
                alert("Notify: " + JSON.stringify(data));
            }
        },
        function (msg) {
            alert("Msg: " + 'onNotification callback successfully registered: ' + msg.Notification);
        },
        function (err) {
            alert("Error: " + 'Error registering onNotification callback: ' + err);
        }
      );
  };
  </code></pre>