I'm trying to build a chrome extension that updates its badge every time some event happens on my server- in this case, my server is receiving a webhook from Zoom and then informing my chrome extension that the event occurred. From there my chrome extension will update a counter on its' badge, to show that the event occured. I'm trying to build it according to the chrome extension Manifest V3 but I can't find any info on how to do this correctly.
To my understanding, in Manifest V3 all client-side scripts must run in a service worker. That service worker starts up, runs some code, and then shuts down again. I was planning to open a websocket in my background script, which would have been fine under manifest v2, but I don't think you can do that any more.
My question is: How do I maintain a connection to receive data in my chrome extension? When I say data in this case I really just mean an event informing my chrome extension to update the counter on its badge.
Are there other routes besides keeping a websocket open in the background? I've looked around at things like Google Cloud Messaging but I don't think that was intended for what I would like to use it for.
Try to use an offscreen API, it was introduced some time ago by Google. You just need to check in which browser version this API is available.
This would give you an opportunity on having long living WS connection and communicate with service worker e.g. by runtime API.
EDIT:
offscreen API is available since Chrome 109
Related
I'm building a Chrome Extension and we published the first version of it recently. We already have a group of users who installed it.
We are now trying to push an update (with bug fixes and new features), but are getting mixed messages from Chrome documentation as it pertains to the user experience for updates. They've mentioned that by default, the updated version will be pushed to the Chrome Web Store, but existing users need to restart their browser for the update to be pushed or manually do to chrome://extensions.
Is there a way to automatically push an update to a user that has already installed our Chrome Extension (without any action required by users)?
We expected the new version to be automatically updated for the existing users. However, when the new version was published, the existing users would still be on the previously version 2-3 days after (without restarting their browser)
We expected the users to automatically access the new version without any action to the browser or extension dashboard.
Normally the browser autonomously checks if there are updates every few hours. If I remember correctly every 4 hours.
Therefore it is unlikely that the browser will not receive the update if the browser has been open for several days.
However, if the extension is MV2, if there is a persistent background script and if at least one extension page is currently open in the browser then the update may be stucked until that page\tab is closed.
Once the latter is closed, the extension should receive and install the update at the next browser check.
If your extension falls into this case then you could define a handler for the runtime.onUpdateAvailable event where you force the reload of the extension.
"Is there a way to automatically push an update to a user that has already installed our Chrome Extension (without any action required by users)?"
If by "a user" you mean "some users but not all",
then you could think of a system that sends a push message from your backend and manage its reception from a service worker which will run the runtime.requestUpdateCheck method only for the desired user(s).
However, this will imply the implementation of a sort of user registration\authentication in order to recognize it at the moment of the forced update request.
Note that you will not be able to selectively allow some users to upgrade while excluding all others. Basically, with this technique you would speed up the update only for one or a part of your users, so this method (not exactly easy to implement) could be overly redundant.
I have written a debugger for K2 SmartForm web pages, as a Chrome custom panel extension, think of the Vue.js or React Devtools for a similar concept but it is Manifest 2 and I need to convert to Manifest 3.
The debugger injects into the user's SmartForm and sends every event generated on the form to the extension. When a user interacts with the form it might rapidly generate three events or 100 events and as it is user generated, the events may be rather sporadic with long pauses between events.
I use a background script to move messages from page to panel but the background script in its current form is going away. The script needs to be long running but I have read there are some issues with service workers spinning down. I think I can open a new tab to run the background script, not perfect, but it’s an option, as the audience is developers, and they’ll understand the rationale. I also wonder if it is easier than rewriting as a service worker before the end of the year (this is a side project).
What is recommended in the current versions of Chrome for keeping a message channel like this open? If it is the background script in a new tab, is there a sample project I can download?
This feels like a shot in the dark but...
Should a single Native Messaging host be able to communicate with the same extension installed on multiple chrome profiles?
I'm working on an extension which is installed to both my personal and work profiles. But it seems that the Native Messaging host only sends messages to the most recently connected instance of the extension.
I don't believe this is addressed in the Native Messaging documentation and I've run out of search ideas, thanks in advance for any help!
When nativeMessaging API is used it starts an instance of native app each time a connection is created by the extension so such an instance can communicate with its "parent" extension only. Consequently, there should be no problem.
In case you want to use chrome.runtime.onConnectNative to do the reverse (to connect from a native app to an extension which will work even when Chrome is closed) see crbug.com/967262 for more info or create a new issue there asking for details. Judging by the bits I see this feature is available only on ChromeOS and it's even disabled by default.
Is that working to make an Chrome Extension that can send Notifications to the user with getting the Informations from Firebase Cloud Service?
I will have an Extension, that i can send users informations with that have installed my extension on all Pages if the have Chrome opened...
Is there any tutorial? I cannot find anything about chrome extensions and firebase
I used this tutorial with some differences with FCM. On extension side I made all by this tutorial, on the server-side - by FCM tutuorial. It works, but at current time messages saved at FCM while browser is shut down don't come after browser open, looking for a bug.
Yes, it wouldn't save messages while browser is shut down.
As long as Chrome is running, even if the extension or app is not running, it is woken up to deliver a message.
The tutorial in the link of the previous answer is now deprecated. "As of April 10, 2018, Google has deprecated GCM.." Learn more here.
Now, you can implement Firebase Cloud Messaging to your Javascript project with this tutorial, See here
I have a chrome packaged app that I update form time to time - when I'm creating an update I want to send email to subscribed customers with a link the that extension -that will launch it.
Anyone knows if there is a chrome url scheme i can use?
Currently this is not possible, but there is an API proposal and an implementation being developed for a chrome-app://appid URL schema that would do pretty much what you describe.
Follow the status here
I also want to be able to do this. It seems that one possible solution is to install both an extension and a packaged app, and have the extension register a context menu that then communicates with the app, or something similar.