You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you're running it in the browser while developing it then are running it on the "web" platform so you need to call this.
Alternatively you can wrap you firebase calls to confirm that this is running on device.
For my code, I don't need it on the web, its only for on device builds so I made a service that wraps my firebase calls, and skips it if its not the right platform:
import{Injectable}from'@angular/core';import{FirebaseAnalytics}from'@capacitor-community/firebase-analytics';import{Platform}from'@ionic/angular';
@Injectable({providedIn: 'root',})exportclassFirebaseAnalyticsLoggerService{constructor(privateplatform: Platform){}asynclogEvent(name: FirebaseAnalyticsEventTypes,value: any){awaitthis.platform.ready();if(!this.platform.is('hybrid')){console.log('Firebase Analytics aborted: not running on a device.');return;}try{constresult=awaitFirebaseAnalytics.logEvent({ name,params: value});console.log('Firebase Analytics Result: ',result);}catch(error){console.error('Firebase Analytics Error: ',error);}}}
This is for an ionic / angular app, if you're working in something else then I believe capacitor has its own platform class.
Describe the bug
Hi there!
I'm using this plugin in my Capacitor app, it works great but every time I start the app y get the following message on console
ERROR Error: Uncaught (in promise): Firebase analytics is not initialized. Make sure initializeFirebase() is called once
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Don't show any error message on the console
Screenshots
Desktop (please complete the following information):
Additional context
Plugin version: 4.0.0
Capacitor version: 4.0.0
The text was updated successfully, but these errors were encountered: