title: FCM using push notification ionic 4
body: <p><strong>FCM using push notification ionic 4<a href="https://i.stack.imgur.com/aQNsq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/aQNsq.png" alt="enter image description here"></a></strong></p>
  
  <p>i had attach my error log too,</p>
  
  <p>i installed <a href="https://i.stack.imgur.com/aQNsq.png" rel="nofollow noreferrer">https://ionicframework.com/docs/native/fcm</a>  </p>
  
  <p>i am using ionic cli---4.12.0</p>
  
  <pre><code>I am trying to send push notification on my device with the help of FCM 
  </code></pre>
  
  <p>and ionic 4. But I'm unable to get token,. I'm getting device token for iOS 
  and I've import <strong>app.module.ts</strong>,<strong>app.component.ts</strong> aslo ,
  i have  try to store token in local storage but im getting null value
  is there i missing??</p>
  
  <pre><code> initializeApp() {
  this.platform.ready().then(() =&gt; {
    this.statusBar.styleLightContent();
    this.splashScreen.hide();
    this.fcm.subscribeToTopic('marketing');
  
  
    //Receving
    this.fcm.getToken().then((token) =&gt; {
      localStorage.setItem('token', token);
    }, (err) =&gt; {
      alert(JSON.stringify(err));
    });
  
  
    this.fcm.onNotification().subscribe((data) =&gt; {
      console.log("Data :", data);
      if (data.wasTapped) {
        console.log("Received in background " + JSON.stringify(data));
        alert("Received in background " + JSON.stringify(data));
      } else {
        console.log("Received in foreground" + JSON.stringify(data));
        alert("Received in foreground" + JSON.stringify(data));
      }
    });
    //Updating
    this.fcm.onTokenRefresh().subscribe((token) =&gt; {
  
      localStorage.setItem('token', token);
      console.log(token);
      alert('refresh token: ' + token);
    });
  
    this.fcm.unsubscribeFromTopic('marketing');
  
  });
  </code></pre>
  
  <p>}</p>