Firebase Analytics runtime error

Hi,

I been searching this error in the web but no luck.

error : “this.fba.logEvent().then() is not a function.”

import { Injectable } from ‘@angular/core’;
import { FirebaseAnalytics } from ‘@ionic-native/firebase-analytics’;

@Injectable()
export class EventLoggerProvider {

constructor(public fba: FirebaseAnalytics) {
console.log(‘Hello EventLoggerProvider Provider’);
}

logButton(name:string,value:any){
this.fba.logEvent(name, { pram:value })
.then((res: any) => {console.log(res);})
.catch((error: any) => console.error(error));
}
}

This is my ionic version.

cli packages: (D:\dev\mobile\final\proj\node_modules)

@ionic/cli-plugin-proxy : 1.5.8
@ionic/cli-utils        : 1.19.3
ionic (Ionic CLI)       : 3.20.1

global packages:

cordova (Cordova CLI) : 8.0.0

local packages:

@ionic/app-scripts : 3.2.1
Cordova Platforms  : android 7.0.0 browser 5.0.4
Ionic Framework    : ionic-angular 3.9.2

System:

Android SDK Tools : 26.1.1
Node              : v8.9.1
npm               : 6.4.1
OS                : Windows 10

Environment Variables:

ANDROID_HOME     : C:\android-sdk
HTTP_PROXY       : not set
http_proxy       : not set
HTTPS_PROXY      : not set
https_proxy      : not set
IONIC_HTTP_PROXY : not set
PROXY            : not set
proxy            : not set

Misc:

backend : pro

I faced that issue only in my browser, once I tested it on my device it worked fine. I think it may be because the plugin doesn’t support browser platform.

The solution I can think of is to do a checking in the platform right before calling the method.

Its now fixed. I used the ‘@ionic-native/firebase’

import { Injectable } from ‘@angular/core’;
import { Firebase } from ‘@ionic-native/firebase’;

@Injectable()
export class EventLoggerProvider {

constructor(public fba: FirebaseAnalytics) {
console.log(‘Hello EventLoggerProvider Provider’);
}

logButton(name:string,value:any){
this.fba.logEvent(“page_view”, { page: name})
.then((res: any) => {console.log(res);})
.catch((error: any) => console.error(error));
}
}

I’m not sure how you got this to work with just Firebase. In your constructor, fba uses FirebaseAnalytics. How did you get it to compile?