Getting null as the token on getToken() in cordova-plugin-fcm

#1

0

I want to implement push notification using ionic 3 and firebase. I am using cordova-plugin-fcm but I am getting the token as null on getToken() . I have already set up the project on firebase and downloaded the google services. When I used this plugin a year back everything was working perfectly. Now when I am using it on my new project I am getting null as the token. Is the getToken() deprecated? I have installed the fcm plugin as well as @ionic-native/fcm . According to the new documentation the plugin is now renamed as cordova-plugin-fcm-with-dependecy-updated , I have tried this too but the result is same. I can’t use the console as native plugins are already installed.

my component.ts

this.fcm.subscribeToTopic('all');
  alert('here');
  this.fcm.getToken().then(token => {
    alert(token);
    localStorage.setItem('token', token);
    alert(token);
  });
  this.fcm.onNotification().subscribe(data =>{
    alert('Your order as been assigned.Please reload the page')
    if(data.wasTapped){
      //alert('background');
    } else {
      //alert('foreground');
    }
  });
  this.fcm.onTokenRefresh().subscribe(token => {
    //alert('token')
  });
1 Like