Commit aadda703 authored by Merzough Münker's avatar Merzough Münker
Browse files

fix: add support for vapid key and message service worker

parent e1b39061
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -96,6 +96,7 @@ export interface FirebaseConfig {
    storageBucket: string | null;
    region: string | null;
    origin: string | null;
    vapid: string | null;
    auth: {
      google: boolean;
      facebook: boolean;
+22 −0
Original line number Diff line number Diff line
@@ -25,6 +25,10 @@ import {
  REGION,
  ORIGIN
} from '@angular/fire/functions';
import {
  VAPID_KEY,
  SERVICE_WORKER
} from '@angular/fire/messaging';

export function FirebaseOptionsTokenFactory(configService: ConfigService<FirebaseConfig>) {
  return configService.get('firebase.options');
@@ -66,6 +70,14 @@ export function DataCollectionEnabledFactory(configService: ConfigService<Fireba
  return true;
}

export function VapidKeyFactory(configService: ConfigService<FirebaseConfig>) {
  return configService.get('firebase.vapid');
}

export function ServiceWorkerFactory() {
  return (typeof navigator !== 'undefined' && navigator.serviceWorker?.getRegistration()) ?? undefined
}

export const FIREBASE_PROVIDERS: Provider[] = [
  {
    provide:    AUTOMATICALLY_TRACE_CORE_NG_METRICS,
@@ -117,6 +129,16 @@ export const FIREBASE_PROVIDERS: Provider[] = [
    useFactory: FunctionsOriginFactory,
    deps:       [ ConfigService ]
  },
  {
    provide: VAPID_KEY,
    useFactory: VapidKeyFactory,
    deps: [ ConfigService ]
  },
  {
    provide: SERVICE_WORKER,
    useFactory: ServiceWorkerFactory,
    deps: []
  },
  {
    provide:    FirebaseApp,
    useFactory: ɵfirebaseAppFactory,