Would appreciated help on a gap in comprehension. Sending push notifications to Chrome running on a Windows 10 machine (tried on older Windows also) results in the notifications popping up only when the Chrome browser is open (similarly for installing the page as a PWA). On numerous sites and posts it says that Chrome can run a background process even when the browser is closed and still receive notifications that will kick off the browser or the PWA.
Have reviewed a number of posts from back in 2015/2016 which don't appear relevant based on current state of service workers, PWAs. Have also looked at the W3C spec and Chromium post on design and architecture which don't really seem to cover how the host OS (e.g., Windows) invokes the browser.
The Chrome browser is set to run in the background (setting->advanced->Continue running background apps when Google Chrome is closed) but on closing Chrome and looking at the running processes on the system, there does not seem to a Chrome background thread running (i.e., it does not seem that Chrome inherently runs some background process). Push notifications (e.g., sent via OneSignal) which result in the appropriate page being opened when Chrome is already open or the PWA receiving the notification (we are currently using GCM not FCM if that makes a difference) if it is open, do not seem to kick off the chrome browser if it is not already running. Otherwise the notifications are processed correctly.
From the google developer site and OneSignal documentation, etc, I had somewhat assumed (apparently incorrectly) that having a service worker for push notification would somehow create a background process environment.
So, the question is, what is required to keep Chrome running in the background to be able to receive the push notifications? Can it be done with a service worker? If the code is in a PWA is that different? Is a Chrome extension required? though having to create an extension would seem contrary to the point of creating the service workers and making the app a PWA.
I note also that it posts indicate that with Firefox this is not possible as Firefox completely exits on close with no background processes.
Any thoughts would be appreciated.
Related
I've just tested Blazor example Blazing Pizza that uses push notifications as a PWA feature on Blazor. I changed public/private keys with my own generated ones and ran the project with MS Edge browser and push notifications worked as desired. But when I open it with Google Chrome, it doesn't shows any notification! (I allowed to show notifications).
I traced service-worker.js and found that notification hits the breakpoint, it means notification receives by browser but not showing:
I checked my Chrome's settings but not found anything to change.
I've found my mistake: I had blocked Google Chrome notifications in my Windows 10 notification settings!
I am currently working on a video web application. We rely on notification to notify provider there is call in.
Firebase works well even when I close the tab. I found that if there is any chrome's thread running in background, I will get notification.
Is there any way that I can make a background thread active even the user click close button on chrome? how about chrome extension? does it approach the goal?
Firebase Cloud Messaging for web relies on a service worker to receive messages when the web app is not active/visible. This requires that Chrome is active.
If the user completely quits Chrome, all tabs, service workers and extensions are stopped. There is no way to still receive web push notifications in that case.
We're developing a website which sends push notifications to end users using GCM. We've gone through Service Worker and all. We have developed a prototype using this codelab tutorial. It is working so far, but the only issue is the notifications are displayed only when Chrome is opened. When Chrome is closed, the notifications don't reach the users.
I want to know is there any way we can overcome this and display the notifications even when the browser is closed, similar to Safari Push Notification. Thanks in advance!
If you have a "background" permission in manifest.json, your background page will be able to show notifications even when Chrome window is closed.
"permissions": [
"background"
],
As stated in the documentation:
When any installed hosted app, packaged app, or extension has "background" permission, Chrome runs (invisibly) as soon as the user logs into their computer—before the user launches Chrome. The "background" permission also makes Chrome continue running (even after its last window is closed) until the user explicitly quits Chrome.
You need to use the "background" permission with a background page, event page or a background window for hosted apps.
For web, use Push API for Chrome and other browsers. The advantage of using push messages is that even if your page is closed, your service worker will be woken up and be able to show a notification. Web Sockets and EventSource have their connection closed when the page or browser is closed so it's not recommended. Here is the documentation and example.
In Chrome. Only those users that happen to have an extension installed that requires background mode, like hangouts, will be able to receive push notifications when chrome is not "running". It does not seem like a good idea to rely on it.
The chrome team seems to be considering it for web push too but so far there is no ETA.
https://code.google.com/p/chromium/issues/detail?id=402456
Showing notification when the browser or tab is closed requires the service worker and a third party service (like google firebase)to trigger the service worker.
https://github.com/web-push-libs/ - Check these list of libraries to implement this in different platforms.
https://github.com/rijoshrc/php-service-worker-push-notification - Clone this git repository to see the simple implementation in PHP.
We have a web application that runs within a VPN. It has a self signed cert on it and is accessed through the server's IP address.
Part of the functionality of this app are some legacy Java apps (that no longer run in Chrome). Our initial work around for our Chrome users was to run Shell In A Box within an iframe of the web app to run those. All was good until the latest version of Chrome, v45.
What we’re seeing is that appears to be blocking the iframed content (maybe because of the self-signed cert?). If we grab the ShellinABox URL and drop it in a new tab, it works as it used to in the iframe. If we go back to the iframe, it now works. If we close Chrome and open it back up, it still works.
I should also note that we tried the canary builds as well. It's up to v47.x and we still see the same behavior there. We were reading through some of the Chrome group/bug lists and saw some reports that were similar but the "fixes" supposedly going through canary still didn't resolve it.
So, it appears that an exception is being logged somewhere. Does anyone have an explanation for this behavior and is there a way to set this exception without jumping through those hoops?
It turned out it was due to a permissions issue with ShellInABox that didn't reveal itself until v45 of Chrome, for some odd reason.
What would be the easiest way for me to set up a Chrome extension that starts when I log in to my Windows account, and can be connected to a WebSocket server to check for, say, new messages, and then pop open a desktop notification, that clicks to the messages web page?
I expect that making an extension is straight forward, as well as getting it to communicate with WebSockets, and making the desktop notification.
But what about making it automatically start when I log in to the computer? What would be a good way to do this in Windows? I am not interested in having the chrome browser to open up at log in, but I certainly don't mind if I see Chrome in the task bar.
You might look into chrome.runtime.onStartUp: https://developer.chrome.com/apps/runtime#event-onStartup, which is
"Fired when a profile that has this extension installed first starts up."
Also, you can use chrome.alarms to schedule a function to run every minute or so, to open a WebSocket somewhere, etc.
The app may try to unload itself if there are no active windows, so you can call some action in chrome.runtime.onSuspend (like loading an XHR somewhere) to cause onSuspendCanceled to trigger.