Getting null value of FCM token


#1

The error:

Error getting token Default FirebaseApp is not initialized in this process com.appname.android. Make sure to call FirebaseApp.initializeApp(Context) first.

import { Component } from '@angular/core';
import { MenuController } from 'ionic-angular';
import { IonicPage, NavController, NavParams, LoadingController } from 'ionic-angular';
import { MyaccPage } from '../myacc/myacc';
import { MyprofPage } from '../myprof/myprof';
import { CommonTasks } from '../../app/common_tasks';
import { Http, Headers } from '@angular/http';
import * as $ from 'jquery';
import 'rxjs/Rx';
import { Firebase } from '@ionic-native/firebase';
import { UniqueDeviceID } from '@ionic-native/unique-device-id';
import { PopoverController } from 'ionic-angular';
import { PopoverPageComponent } from '../../components/popover-page/popover-page';

//import { InAppBrowser } from '@ionic-native/in-app-browser';

@Component({
  selector: 'page-home',
  templateUrl: 'home.html'
})
export class HomePage {

  constructor(public navCtrl: NavController, public navParams: NavParams, public commonTasksObj: CommonTasks, public http: Http, public loadingCtrl: LoadingController,public menu: MenuController, private firebase: Firebase, private uniqueDeviceID: UniqueDeviceID, public popoverCtrl: PopoverController) {
   
  }
 
  ionViewDidEnter() {
    this.menu.swipeEnable(false);
    this.firebase.getToken()
    .then(token =>console.log(token))
    // .then(token =>localStorage.setItem("FCMTOKEN",token.toString()))
    .catch(error => console.error('Error getting token', error));
    console.log(localStorage.getItem("FCMTOKEN"));
    this.uniqueDeviceID.get()
    .then((uuid: any) => localStorage.setItem("UUID",uuid))
    .catch((error: any) => console.log(error));
    console.log(localStorage.getItem("UUID"));

    this.firebase.onNotificationOpen().subscribe(res => console.log(res));
  }

I’m trying to implement Push notfication but getting null value of FCM token in console.