Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

863
Vistas
Uncaught SyntaxError: Cannot use import statement outside a module in Angular & Firebase

I got this error in Angular when try to connect firebase push notification setting. enter image description here

import { initializeApp } from 'https://www.gstatic.com/firebasejs/9.1.0/firebase-app.js';
import { getMessaging, isSupported, onBackgroundMessage } from 'https://www.gstatic.com/firebasejs/9.1.0/firebase-messaging-sw.js';
    
    // Initialize the Firebase app in the service worker by passing in the
    // messagingSenderId.
    
    const firebaseApp = initializeApp({
      apiKey: "",
      authDomain: "",
      projectId: "",
      storageBucket: "",
      messagingSenderId: "",
      appId: "",
      measurementId: ""
    });
    
    // Retrieve an instance of Firebase Messaging so that it can handle background
    // messages.
    isSupported().then(isSupported => {
    
      if (isSupported) {
    
        const messaging = getMessaging(app);
    
        onBackgroundMessage(messaging, ({ notification: { title, body, image } }) => {
          self.registration.showNotification(title, { body, icon: image || '/assets/icons/icon-72x72.png' });
        });
    
      }
    
    });
over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

You need to tell it it's a module when you register a service worker

See this resolved issue on GitHub: https://github.com/angular/angularfire/issues/3049#issuecomment-963388580

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda