'Dynamically update “firebase-messaging-sw.js” in Angular 12

I need to implement the Firebase push notification on Angular 12.

I integrated everything and it worked fine, but I need a dynamic firebase config. How to achieve dynamic config?

importScripts('https://www.gstatic.com/firebasejs/4.6.1/firebase-app.js');
importScripts('https://www.gstatic.com/firebasejs/4.6.1/firebase-messaging.js');


firebase.initializeApp({
  'messagingSenderId': '192*******9'
});
const messaging = firebase.messaging();


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source