Bacancy Technology
Bacancy Technology represents the connected world, offering innovative and customer-centric information technology experiences, enabling Enterprises, Associates and the Society to Rise™.
12+
Countries where we have happy customers
1050+
Agile enabled employees
06
World wide offices
12+
Years of Experience
05
Agile Coaches
14
Certified Scrum Masters
1000+
Clients projects
1458
Happy customers
Artificial Intelligence
Machine Learning
Salesforce
Microsoft
SAP
July 2, 2024
firebase.messaging needs a SW registration. If you don’t specify a registration, it creates a new registration at the root level and needs a firebase-messaging-sw.js file at the root
useServiceWorker is deprecated
Registration can be passed when you getToken():
if ("serviceWorker" in navigator) { navigator.serviceWorker .register("./firebase-messaging-sw.js") .then(function(registration) { console.log("Registration successful, scope is:", registration.scope); messaging.getToken({vapidKey: 'YOUR_VAPID_KEY', serviceWorkerRegistration : registration }) .then((currentToken) => { if (currentToken) { console.log('current token for client: ', currentToken); // Track the token -> client mapping, by sending to backend server // show on the UI that permission is secured } else { console.log('No registration token available. Request permission to generate one.'); // shows on the UI that permission is required } }).catch((err) => { console.log('An error occurred while retrieving token. ', err); // catch error while creating client token }); }) .catch(function(err) { console.log("Service worker registration failed, error:" , err ); }); }