Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get ServiceWorkerRegistration object? #156

Closed
iarmankhan opened this issue Feb 5, 2021 · 1 comment
Closed

How to get ServiceWorkerRegistration object? #156

iarmankhan opened this issue Feb 5, 2021 · 1 comment
Labels
bug Something isn't working done

Comments

@iarmankhan
Copy link

Summary

I'm currently trying to implement FCM in my PWA and from the firebase docs it is said to have service worker with exactly name firebase-messaging-sw.js or to provide a ServiceWorkerRegistration object to getToken method.

Now, I can use the sw parameter in next-pwa to rename the output file and it is working but I think it would be better if I can get the object instead of renaming the whole file just for one thing.

Firebase getToken documentation: Here

Thank you

@iarmankhan iarmankhan added the bug Something isn't working label Feb 5, 2021
@shadowwalker
Copy link
Owner

You can use this to get the registration object

navigator.serviceWorker.getRegistrations().then(function(registrations) {
 for(let registration of registrations) {
  console.log(registration)
} })

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working done
Projects
None yet
Development

No branches or pull requests

2 participants