Cordova-plugin-firebase: (Property ‘FirebasePlugin’ does not exist on type ‘Window’)

Created on 28 May 2017  Â·  6Comments  Â·  Source: arnesson/cordova-plugin-firebase

I watched the steps exactly but I get an error.

app.component.ts

  import { Component } from '@angular/core';
  import { Platform } from 'ionic-angular';
  import { StatusBar } from '@ionic-native/status-bar';
  import { SplashScreen } from '@ionic-native/splash-screen';

  import { HomePage } from '../pages/home/home';



 @Component({
  templateUrl: 'app.html'
 })


 export class MyApp {
    rootPage:any = HomePage;


   constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen) {
     platform.ready().then(() => {

      statusBar.styleDefault();
      splashScreen.hide();



       window.FirebasePlugin.getToken(function(token) {
      // save this server-side and use it to push notifications to this device
         console.log(token);
        }, function(error) {
       console.error(error);
     });

       Window.FirebasePlugin.onNotificationOpen(function(notification) {
         console.log(notification);
      }, function(error) {
      console.error(error);
     });

      });

      }
   }

`

Most helpful comment

Caused by using TypeScript with out the proper types. You can get around this by doing:

const plugin = (<any>window).FirebasePlugin;
// or
const plugin = (window as any).FirebasePlugin;

All 6 comments

do not use capital W

even without the capital, the error persist

Same here, was this solved?

I solved using another plugin : cordova-plugin-fcm

Caused by using TypeScript with out the proper types. You can get around this by doing:

const plugin = (<any>window).FirebasePlugin;
// or
const plugin = (window as any).FirebasePlugin;

I solved using another plugin : cordova-plugin-fcm

FCM breaks on Android 7.1.1 for Ionic. @rwoody solution works.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rolinger picture rolinger  Â·  3Comments

danielpalen picture danielpalen  Â·  5Comments

michaelreiser picture michaelreiser  Â·  5Comments

matthitachi picture matthitachi  Â·  5Comments

rolinger picture rolinger  Â·  5Comments