-
Notifications
You must be signed in to change notification settings - Fork 290
Google Cloud Messaging (GCM) or Firebase? #27
Comments
How to send response to SERVER and get notification.... I need server side code.. please help |
Where are you seeing a reference to GCM? https://developers.google.com/web/fundamentals/getting-started/codelabs/push-notifications/ The only reference is at the very end regarding how to deal with old / non-standard browsers. Regarding server side code, are you tried looking at the web-push libraries referenced in the code lab? Otherwise a full node demo can be found here: https://github.com/gauntface/web-push-book/tree/master/src/demos/node-server |
Hello, I am trying to cover the basic scenario of having one user to register on multiple devices and having this one to receive notification from the server. I got some success, but the documentation is lacking and often refer to Android (which I do not mind since I just want browser notification). What I did is refered here for client side and here for server side. The problem is it's working only with a single device since I am storing the token on the server which come from the last device registered by the user. The official multiple devices documentation for Web introduces multi device and topics (at the same time) and at some point just doesn't give any detail about how to subscribe/unsubscribe and send for multi device and partially cover topic. For example, this page doesn't even say to send a HTTP request "DELETE" to unsubscribe (from topic or device), I had to figure that out in an Android page. Now, I am experimenting the use of TOPICS instead of the "device" to represent a user. On every device, the user subscribe to a topics/. And the server send a notification to topics/. So far it works but I cannot delete the message token in the scenario that the user do not want to user notification (I just successfully remove from his topic). I am using the code in this repository (the only example, undocumented) that use My new server code with Topics to handle multiple user devices looks like this to register a new device:
To send a message, I am sending like I am doing in the first link I posted with a POST to https://fcm.googleapis.com/fcm/send. I found odd that I have 2 different URL (one with FCM and one with iid). On the client side, I am doing as mentioned in this repository. Like I said, the problem is to unsubscribe as well as I found it awkward that I need to use topics for multiple devices. |
It sounds like you are mixing up web push and Firebase Cloud Messaging. Web Push is the web standard, Firebase Cloud Messaging does some magic behinds the scenes to return a firebase token that can be used with the Firebase Cloud Messaging API (NOT web push protocol). This is the incorrect place to be asking for help, a better place would be to click the "Send Feedback" button on the top right of the documentation page you linked to. That being said - Firebase Cloud Messaging will always return a token if you call getToken, this is by design. The expectation is that you simply don't send a message to a token if they unsubscribe OR you call deleteToken and save state that the user does not want to receive messages. |
This repository explains Push Notification with Google Cloud Messaging (GCM) account but at this time, when trying to access the Google Cloud Messaging (GCM) account, the page refer to use Firebase. In fact, I couldn't find a way to get a API key that work with Google Cloud Messaging (GCM). My understanding is that it is deprecated. Is the documentation will be updated or we should just rely on the Firebase documentation from this point?
The text was updated successfully, but these errors were encountered: