title: I do not receive FCM Push Notifications with the application closed. Ionic 3 and Angular
body: <p>Good day folks, it is my first publication on the site, I apologize if I do not comply with all the publication rules because I do not know them in detail.</p>
  
  <p>Step to comment my problem .. I have an app made with ionic 3 and angular, which works with notifications between users to emerge an action, investigate the firebase forums and several other places and tried several codes but I could not fix it. The application sends data and notification to a specific token, the device registered by the token receives the data but not the notification. Not when it is with the application open, or when it is in the background or closed. This is the code you use:</p>
  
  <p><strong>1) To receive the token</strong></p>
  
  <pre><code> this.fcm.getToken (). then (token =&gt; {
  
           alert ('token' + JSON.stringify (token))
  
           // Here I save the token I receive from the device
        })
  </code></pre>
  
  <p>This works .. I can get the device token.</p>
  
  <p><strong>2) To receive the notification:</strong></p>
  
  <pre><code>this.fcm.onNotification (). subscribe (data =&gt; {
          if (data.wasTapped) {
            alert ("Received in background")
          } else {
            alert ("Received in foreground")
          };
        })
  </code></pre>
  
  <p>This also works, <strong>when I sent a notification from the firebase console I get it perfectly</strong> .. the problem is when I sent it from the server</p>
  
  <p><strong>3) Code for notification:</strong></p>
  
  <pre><code>SendNotific ()
  {
  let keytoken = 'fqN5yelN7gk: APA91bGT0 ......'
  let keyserver = 'AAAA4oCrTNk: APA91bHLBWcyQimF ....'
  let headers = {'Authorization': 'key =' + keyserver,
  'Content-Type': 'application / json'};
  let url = 'https://fcm.googleapis.com/fcm/send';
  let body = {
  "notification":{
  "title": "notification title",
  "body": "notification body"
  },
  "data":{
  "key1": "value1",
  "key2": "value2"
  },
  "to": keytoken,
  "priority": "high",
  "content_available": true
  }
  
  this.http.post (url, body, headers) .then (data =&gt;
  {
  alert (JSON.stringify (data))
  
  }). then (error =&gt; {
  alert ('error' + JSON.stringify (error))
  })
  }
  </code></pre>
  
  <p><strong>If the application is in the foreground of the device</strong>, the alert becomes visible, that is, I receive the data that I sent in "Data". (For this case it would be "key1" and "key2") but I do not receive any notification. <strong>If the application is in the background or closed</strong>, no notification is shown, and when I open the app again the alert messages are shown with the "Data" that arrived.</p>
  
  <p>As I said before, <strong>if you sent a notification from the Firebase console it works perfectly ..</strong></p>
  
  <p>Clearly I'm missing some data that I can not find .. I saw several publications that talk about the same thing but I can not give the solution ..</p>
  
  <p>Will I be missing specific data within the notification so it can be visible?</p>
  
  <p>Does the user need to accept any permission to receive the notification?</p>
  
  <p>Thank you very much and sorry if I could not explain clearly</p>
  
  <p>regards,</p>
  
  <p>Julian.</p>