-
Notifications
You must be signed in to change notification settings - Fork 15.4k
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
Chrome Web Push support #6697
Comments
+1 for this. Hope it will get implemented. As of today, Electron's notifications are not consistent, because native notifications aren't. On some systems they are shown on top right corner of the screen (mac os, ubuntu), some on bottom right corner (windows 10, kubuntu); on some systems they are clickable (kubuntu, mac os), on some they are not (ubuntu) |
This probably won't be implemented because there's a fair amount of custom UI associated with it (i.e. Chrome runs a process in the background, it puts an item in the notification area on Windows, etc etc etc) |
I think the value is in the push mechanism, not in the UI. Electron could just provide an API to execute a callback when a message is received and the app can decide what to do with the message - there's no need to implement UI in electron. |
@biiiipy I'm not talking about the message itself, but the UI to be able to decide whether you allow a process to run on startup: At the end of the day, push notifications aren't magic, somebody is running in the background picking up the phone. Electron could plumb this into an API, but it could potentially be pretty Complicated and Not-User-Intuitive |
For people wanting a custom notification interface: we are never going to add that, we will stick to the system notifications. This issue is about possibly supporting the Web Push protocol, instead of Chrome's notification system. |
Has anything changed? |
I'm new to Electron so I can't say I quite understand all of the platform differences: however since the standardization of the Push Api, isn't this a Chromium and not a Chrome specific feature? The Chromium runtime docs show PushMessaging as a stable feature. Is it just a matter of enabling it in the electron Build? I've tried using blinkfeatures and webpreferences settings on a webview but haven't had any luck. Would be great if this was a simple flip of a switch. I'd hate to have to bail on FCM since its nicely integrated with the rest of my app. https://cs.chromium.org/chromium/src/third_party/WebKit/Source/platform/RuntimeEnabledFeatures.in |
+1 for this. In the browser project that I'm working on (described in #8534), I'd really like to make the start page (when you start a browser or add a tab) a feed type list of your recent HTML5 notifications. For me this is much better than a modal that interrupts. It's also probably the first step in a true open source type facebook thingy. I would propose electron simply add a runInBackground attribute in BrowserWindow and let the UI decide how to handle any inbound notifications with a generic event. |
+1, need this too. |
+1, this is really a needed feature. |
+1, would be awesome to add this. |
In my application, some page is open with |
Will there be a way to configure your own push notification service? |
@zoonman is there any service we can use already? As this issue is still open, can I assume push notifications to electron (not the UI bit but the push from the server to the client) is still not possible? |
@caleboau2012 as I know it is not available for now. But, because electron has a node process running all the time, you can hook it up to something like Firebase and use it a as transport layer. And send notifications using regular Notifications API. |
I read back through this thread, and it really does seem like every other person is talking about a different thing. I just wanted to clear something up for future readers. People are requesting these two separate but related things:
For the Electron team, What I still don't understand on point #2 is that Node-Webkit has been able to enable this. You should be able to build Electron with it enabled as it doesn't appear that NW did anything special to achieve this other than turning on a flag and providing the same global API key for GCM that Chrome does. It was a bummer on my last project because I was using Firebase Cloud Messaging which relies on the push spec, and was forced to go with NodeWebkit even though I definitely wanted to use Electron ;). |
Thanks @jamesmfriedman. #2 is a more pertinent issue to me. @zoonman, if there is, can you share a link to any helpful guides for hooking electron up to firebase (using it as a transport layer) |
The workaround he's talking about definitely won't work with Firebase Cloud Messaging since it requires the browsers Push Api. You could only use it for your own home rolled notifications service.
…Sent from my iPhone
On Jul 6, 2017, at 6:02 PM, Mbakwe Caleb ***@***.***> wrote:
Thanks @jamesmfriedman. #2 is a more pertinent issue to me.
Are you implying that there is no workaround like @zoonman suggested.
@zoonman, if there is, can you share a link to any helpful guides for hooking electron up to firebase (using it as a transport layer)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
ServiceWorker.prototype.showNotification and window.PushManager are both override-able. I just checked. So theoretically people could inject their own impls of this svc in their webviews and it should all just work. |
Yep, went down that path. Also not doable since there's nothing you can override it with that's going to work when the client is closed.
…Sent from my iPhone
On Jul 6, 2017, at 6:42 PM, ericbets ***@***.***> wrote:
ServiceWorker.prototype.showNotification and window.PushManager are both override-able. I just checked. So theoretically people could inject their own impls of this svc in their webviews and it should all just work.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
@caleboau2012 you will need to start here https://github.com/firebase/quickstart-nodejs Basically you will need to implement broacaster-observer pattern. You will need a separate app which will be server and it will be responsible for broadcasting messages. If you think that work with Firebase is too complicated, you can use server-side websockets to communicate between Electron app and your server. |
@zoonman there are absolutely other ways you can receive messages in the background, what you're referencing in your post is the Firebase Database. Firebase is a conglomeration of services, the particular one I was talking about is Firebase Cloud Messaging https://firebase.google.com/docs/cloud-messaging/. But none of this is about Firebase... Sure, you can find a work around way to receive background notifications and data with Electron, but there is a built in browser Push api that is supported in official Chrome and Node Webkit, and Electron just doesn't appear to be enabling it in its Chromium build. |
@jamesmfriedman you are correct, Firebase is not the best choice here. Also, "Cloud Messaging" is based upon PushManager. Anyway, Electron app must be running in order to establish connection to server side. And I agree that builtin browser Push API must be exposed alongside with its settings. |
Yeah @zoonman, spot on. I actually don't know how Chrome handles this for its ServiceWorkers when it's closed, but there is for sure something listening for incoming push messages. I don't know what is different about Node Webkit, but it does "just work" without any additional configuration, other than a flag to enable Google cloud messaging http://docs.nwjs.io/en/latest/References/Command%20Line%20Options/#-enable-gcm. |
@jamesmfriedman The difference with nw.js is that electron is based on Chromium Content using libchromiumcontent and not on the whole Chromium browser. To enable Push Notifications support, the browser needs to maintain an active connection to a push service in order to receive push messages as long as it is open. Unfortunately, the integration with a push service (FCM for chromium/chrome) is not part of the Content API. Therefore if you try to run : serviceWorkerRegistration.pushManager.subscribe() it will raise :
You can reproduce it using Content Shell which is a basic browser built on top of the Content API. |
This might be a little off-topic, but would it be possible to integrate directly with the Mac Push Notification API? For Mac, we at least wouldn't need any background processes running and the OS will handle everything for us. |
@MatthieuLemoine thank you so much!!! All I wanted to know was why, it was driving me crazy. At least now that I know the limitation I can work around it. |
@jamesmfriedman have you found a workaround for this ? |
I created a Push notification client named push-receiver to be able to receive Web Push notification in Node & Electron like Chrome does. There's also an electron wrapper named electron-push-receiver. If you're interested in the I'm looking for contributors that would be willing to try it and work on it. |
@MathieuDebit thanks for your work! It looks promising! I'll try it out! |
@MatthieuLemoine Thanks for doing this. Saw your post and I'll be playing with it here soon. Almost a year later but better late than never of course. I can't believe this is still an issue though. |
For anyone still interested, Pushy has just released an open source package for sending push notifications to Electron apps using a background MQTT connection: Full disclosure: I work for Pushy. |
For what it's worth, I don't think running on startup is an issue that needs to be solved by electron as such. Chrome starts a service in the background at startup if it is requested to do so, but I've noticed that Firefox doesn't. I think it would be completely acceptable to just poll for push notifications during electron's run time and then that would seem to mirror Firefox's behaviour. |
Issue is still present in the recent Electron version:
I tried integrating Firebase Cloud Messaging and it finally failed on "obtaining an FCM token" step with following error message:
Pretty obvious that it's about {this} issue. MatthieuLemoine's solution from https://github.com/MatthieuLemoine/electron-push-receiver was easy to integrate and works like a charm. Thanks, Matthieu! |
any progress? I really need this |
With the Apple ecosystem supporting the Web Push API, PWAs now have a huge advantage over Electron-based apps. It is really necessary to implement a way to support push messaging globally in Electron—not necessarily through the Web Push API, but by using OS-native push support (Apple has the Notifications API, Windows also has push notifications through the Windows App SDK, etc.). |
I came across this previous issue, where it was said that Chrome Push would not be supported at the time since Google's private services are not included in Electron's content bundle. Now that Chrome 52 supports a non-proprietary protocol, would Electron eventually support web push notifications?
The text was updated successfully, but these errors were encountered: