maximegris / angular-electron

Ultra-fast bootstrapping with Angular and Electron :speedboat:
https://www.maximegris.fr/angular-electron/
MIT License
5.67k stars 1.37k forks source link

Firebase Not working in desktop app while it's working in (Web Serve & Build) #770

Closed anoop-mobi closed 1 year ago

anoop-mobi commented 1 year ago

Steps to reproduce

Just open the exe file you will se error in console https://github.com/anoop-mobi/electronTestFirebase

✔️ Expected Behavior

Firebase should be worked. I was implementing this https://github.com/bezkoder/angular-16-firebase-crud in that electron but not worked for me

🔍 Additional context

After A long R'N'D I came here to rise this request I hope you will provide any best solution how it would be worked in electron. I'm trying to do something like show desktop notification when any data come into the list

image

and you can see what in web showing image

maximegris commented 1 year ago

You may have a look at this workaround. https://github.com/angular/angularfire/issues/3181#issuecomment-1501129294 The issue is not related to this project.

anoop-mobi commented 1 year ago

Thankyou so much for providing the solution I'm putting my code here so that other can get help with it

Service.ts import { Injectable, inject } from '@angular/core'; import { Database, child, get, getDatabase, onValue, ref } from '@angular/fire/database'; import { Observable } from 'rxjs';

@Injectable({ providedIn: 'root' }) export class FirebaseService { private database: Database = inject(Database);

setUsingRealtimeDatabase(orderKey: string): Observable { const db = getDatabase(); const starCountRef = ref(db, 'orders');

return new Observable((observer) => { onValue(starCountRef, (snapshot) => { const data = snapshot.val(); observer.next(data); }, (error) => { observer.error(error); }); }); } }

app.module.ts

import { provideFirebaseApp, initializeApp } from '@angular/fire/app'; import { getDatabase, provideDatabase } from '@angular/fire/database';

@NgModule({ .../

imports: [ provideFirebaseApp(() => initializeApp(environment.firebaseConfig)), provideDatabase(() => getDatabase()), ] })