Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

860
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda