Open rockmandash opened 2 years ago
According to the code below, when a user clicks the notification from FCM, it can only open the same domain.
https://github.com/firebase/firebase-js-sdk/blob/cdada6c68f9740d13dd6674bcb658e28e68253b6/packages/messaging/src/listeners/sw-listeners.ts#L130-L136
It would be fantastic if we could open a URL from another domain.
For the time being, I've devised a workaround: directly above the call to firebase.messaging(), insert your own notificationclick:
firebase.messaging(),
notificationclick
self.addEventListener('notificationclick', event => { const url = event.notification.data.FCM_MSG.notification.click_action clients.openWindow(url) }) firebase.messaging()
It is necessary to install an event listener sooner rather than later since it will be halted by the following line:
https://github.com/firebase/firebase-js-sdk/blob/cdada6c68f9740d13dd6674bcb658e28e68253b6/packages/messaging/src/listeners/sw-listeners.ts#L121-L122
Up for this current thread, I'm having this same issue :/ There's any update ?
[REQUIRED] Describe your environment
[REQUIRED] Describe the problem
According to the code below, when a user clicks the notification from FCM, it can only open the same domain.
https://github.com/firebase/firebase-js-sdk/blob/cdada6c68f9740d13dd6674bcb658e28e68253b6/packages/messaging/src/listeners/sw-listeners.ts#L130-L136
It would be fantastic if we could open a URL from another domain.
For the time being, I've devised a workaround: directly above the call to
firebase.messaging(),
insert your ownnotificationclick
:It is necessary to install an event listener sooner rather than later since it will be halted by the following line:
https://github.com/firebase/firebase-js-sdk/blob/cdada6c68f9740d13dd6674bcb658e28e68253b6/packages/messaging/src/listeners/sw-listeners.ts#L121-L122