8

I am trying to do web push notifications in Chrome without using GCM/FCM. Is it possible? I'm not able to find examples on how to use a different push service.

Marco Castelluccio
  • 10,152
  • 2
  • 33
  • 48
godot101
  • 305
  • 1
  • 4
  • 12

5 Answers5

7

No, it is not possible to use another push service.

In Firefox, you can do it by modifying the dom.push.serverURL preference, but obviously you'd need privileged access to alter the value of the pref.

There are third-party services that you can use to implement push notifications, but they will use the Web Push API under the hood (so Autopush on Firefox, GCM/FCM on Chrome).

Marco Castelluccio
  • 10,152
  • 2
  • 33
  • 48
  • Hey 2 quick questions, for chrome: 1. Is there any link/resources on how does GCM/FCM talk to the browser? 2. How does browser talk to service worker? Can we write a script in browser(chrome) to wake up service worker? – godot101 Jan 25 '17 at 11:50
  • 1
    GCM is proprietary, so I don't know. FCM/Autopush are different implementations of the Web Push standard: https://tools.ietf.org/html/draft-ietf-webpush-protocol-12. – Marco Castelluccio Jan 25 '17 at 11:57
  • 1
    FCM is closed source. You can look at the Autopush source code here: https://github.com/mozilla-services/autopush. They are different, but they both support the same standard, so you can look at the Autopush source to get an idea of what FCM does too. – Marco Castelluccio Jan 25 '17 at 12:03
  • Hey Marco, can background sync be used to pull messages - and display notification even when the browser is closed? As shown in https://developers.google.com/web/updates/2015/12/background-sync – godot101 Jan 31 '17 at 12:33
  • This is an unrelated question, can you post it as a question and include more details? – Marco Castelluccio Jan 31 '17 at 13:51
6

Yes. Using VAPID spec and service worker you can use web push notifications without FCM/GCM. For more information please look into below google docs.

https://developers.google.com/web/fundamentals/engage-and-retain/push-notifications/how-push-works

Mathi kumar
  • 373
  • 1
  • 4
  • 10
  • 1
    another good reference for using VAPID instead of `gcm_sender_id` https://developers.google.com/web/updates/2016/07/web-push-interop-wins – Nataly87 Jun 20 '17 at 15:36
  • To clarify, you still need cloud server running somewhere... the browser can't do it by itself. – Ray Foss Aug 14 '18 at 14:44
  • 8
    This is not true -- VAPID on Google Chrome will still use FCM behind the scenes to deliver notifications to Chrome over a dedicated FCM connection. – Elad Nava Sep 19 '18 at 03:12
  • 1
    at least you do not need to create all the complex Firebase project setup. Thats super important to me – ciekawy Aug 21 '20 at 15:55
0

I have used Using VAPID for WebPush. This works in Firefox and IE Edge browser. But not mail in Chrome browser. Again in Firefox action seems to be not working. Whereas in IE Edge, notification actions buttons will work

-2

It can be done using Service Workers. It's new w3c feature. I've not tried it yet, but you can have a look at it:
https://developers.google.com/web/fundamentals/getting-started/codelabs/push-notifications/

It's not compatible with all browsers. Ref.: http://caniuse.com/#feat=serviceworkers

Programmer
  • 443
  • 1
  • 4
  • 13
  • Any more details on this? [Here](http://stackoverflow.com/questions/40167227/can-service-worker-push-notification-without-gcm-in-chrome) it says that only GCM services can be used for ServiceWorkerRegistration.pushManager.subscribe in chrome – godot101 Jan 24 '17 at 11:50
  • gcm_sender_id is used for old browsers like Chrome (version 51 and before), Opera for Android and the Samsung Internet Browser. For the updated browser, you don't need one. Ref. https://web-push-book.gauntface.com/chapter-06/01-non-standards-browsers/ – Programmer Jan 24 '17 at 11:55
  • 3
    By using the Web Push API from a Service Worker, you are going to use GCM or FCM in Chrome. – Marco Castelluccio Jan 24 '17 at 13:03
-2

good grief the advice here is DISGUSTINGLY bad

yes you can do it using https websockets and also a Microsoft project called SignalR which doesn't even "need" browser support, i.e it will work in javascript no matter what

the reason I mention SignalR is that is DEGRADES the mechanic to the bet fit to ensure it works whatever the weather.. tools they use are

  • from old sckoole long polling
  • all the way up to WebSockets under the covers when it's available

(and gracefully fall back to other techniques and technologies when it isn't, while the application code remains the same)

Mr Heelis
  • 2,370
  • 4
  • 24
  • 34
  • that's as maybe... but it also happens to be the only right answer, and my level of utter scorn was absolutely proportionate – Mr Heelis Nov 04 '22 at 13:38
  • [I've retracted my previous comment as it wasn't productive at all.] – jg6 Nov 22 '22 at 05:31