Firebase: change the location of the service worker

后端 未结 3 687
悲哀的现实
悲哀的现实 2020-11-29 06:01

I am trying to use Firebase messaging (web). Firebase by default searches for the file \"firebase-messaging-sw.js\" which holds the service worker.

The service work

3条回答
  •  借酒劲吻你
    2020-11-29 06:23

    By using useServiceWorker(registration) you can use notificationonclick event on Firebase push messaging via exiting service worker.

    firebase.messaging().useServiceWorker(registration) is working and solved my problem, but keep in mind that I don't know if:

    • this is a secure way to get payload from the server.

    • this is the best way to handle push notifications.

提交回复
热议问题