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

时光怂恿深爱的人放手 提交于 2020-01-15 02:55:28

问题


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')
  });

来源:https://stackoverflow.com/questions/55135967/getting-null-as-the-token-on-gettoken-in-cordova-plugin-fcm

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!