Tuesday 26 February 2019

Firebase import not initializing in constructor ionic native

I am working on ionic fcm push notifications. I have imported

import { Firebase } from '@ionic-native/firebase'; but I not able to initialize Firebase in constructor. This is my code

import { Injectable } from '@angular/core';
import { Firebase } from '@ionic-native/firebase';
import { Platform } from 'ionic-angular';
import {HttpClient, HttpHeaders} from '@angular/common/http';

@Injectable()
export class FcmProvider {

  constructor(private platform: Platform, 
              public firebaseNative:Firebase,
              public http: HttpClient) {
    console.log('Hello FcmProvider Provider');
  }

  // Get permission from the user
  async getToken() {
    let token;

    if (this.platform.is('android')) {
      token = await this.firebaseNative.getToken()
    }      
  }
  }
}

I am getting error at

constructor(private platform: Platform, 
              public firebaseNative:Firebase,

It is saying

Cannot find name Firebase

I am following this article.

I have installed npm i @ionic-native/firebase and npm i @ionic-native/fcm packages still not getting it. For more information see screenshot :

enter image description here

How can I solve this issue?



from Firebase import not initializing in constructor ionic native

No comments:

Post a Comment