Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

858
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!