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
Request for an interface in fcm-js-sdk , where we can set the userVisibleOnly property to false #8042
Comments
Hi @balu-mohan, thanks for reaching out to us. The ticket has been filed as the feature request for internal tracking b/326572996. Please note that we cannot provide an ETA at this time. If you have any more suggestions or questions, feel free to let us know. |
Thanks lots @jbalidiong for taking this as a feature request. Hope to see this implemented soon. |
Hello @jbalidiong , is there any updates on this ?? |
I would love to hear an update on this too. As the deadline for Manifest V3 comes closer for Chrome extensions (only a few more months!), existing extensions that relied on the old MV2 always-running background script need to change to work with an event-triggered service worker model. For my project this meant moving from Firestore listeners to FCM Messaging for triggering background data sync functionality. It all works though the problem is now that the users will be spammed with these notifications every time a data change comes in, which can happen many times a minute - which is obviously not acceptable from a user POV. I doubt I'm the only Firebase user in a similar situation, needing to fix this before the MV3 deadline. |
I managed to (mostly) fix this for my MV3 Chrome extension use-case by using Though I found one case where it still happens:
This case seems to be different from all the others which |
Operating System
MacOSX Ventura 13.6.4
Browser Version
Chrome 121.0.6167.160
Firebase SDK Version
10.8.0
Firebase SDK Product:
Messaging
Describe your project's tooling
Chrome browser extension wih React Redux Webpack Jest
Describe the problem
An annoying notification ( This site has been updated in the background ) is shown by default in fcm onBackgroundMessage handler
We are able to suppress the notification if we set the userVisibleOnly property to false by modifying the firebase js sdk.
Also based on this thread: https://groups.google.com/a/chromium.org/g/chromium-extensions/c/F1OOx-8b8BE/m/wtg2If66AAAJ?utm_medium=email&utm_source=footer
Google Chrome now supports setting of the userVisibleOnly property to false from version 121 onwards (This is only for chrome extensions ).
.
Request your help to expose a new interface which accepts options to set userVisibleOnly property as false if required. In the latest firebase-js-sdk ( version 10.8.0 ), we saw that the userVisibleOnly property is hardcoded to true when we use getToken api from the client. ( firebase-js-sdk token-manager.ts : Line number- 165)
async function getPushSubscription(
swRegistration: ServiceWorkerRegistration,
vapidKey: string
): Promise {
const subscription = await swRegistration.pushManager.getSubscription();
if (subscription) {
return subscription;
}
return swRegistration.pushManager.subscribe({
userVisibleOnly: true,
// Chrome <= 75 doesn't support base64-encoded VAPID key. For backward compatibility, VAPID key
// submitted to pushManager#subscribe must be of type Uint8Array.
applicationServerKey: base64ToArray(vapidKey)
});
Steps and code to reproduce issue
Install any chrome extension which uses fcm messaging on Chrome browser version 121.
Register/Subscribe for an fcm message using the the fcm messaging sdk getToken api
Now publish a message so that the onBackgroundMessage handler receives a new fcm messaging payload
We can now see a default Chrome browser notification which will be similar to the one below.
The text was updated successfully, but these errors were encountered: