Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
anoop-mobi opened this issue Aug 12, 2023 · 2 comments
Labels

Comments

@anoop-mobi
Copy link

anoop-mobi commented Aug 12, 2023

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

@anoop-mobi anoop-mobi added the bug label Aug 12, 2023
@maximegris
Copy link
Owner

You may have a look at this workaround.
angular/angularfire#3181 (comment)
The issue is not related to this project.

@anoop-mobi
Copy link
Author

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()),
]
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants