-
Notifications
You must be signed in to change notification settings - Fork 11
Push Notifications
We are using Google Cloud Messaging for push notifications. The API for push notifications is designed to be as close to the API for web sockets as possible, which is in turn designed to be as close to the HTTP API as possible :) Hopefully this means they're all fun to work with.
In order to keep it simple, we're using the topic messaging features of GCM. Only resources with public read access are allowed to have a GCM topic (because there isn't a great way to authorize subscriptions to a GCM topic). Currently, that means there are two topics: messages
and events
.
So, to get push notifications for messages, you need to subscribe to the messages topic. When a GCM push is sent, it gets data attached. The data contains two important keys: action
and document
. The action
tells you what you should do with the document
(create, update, delete, notify). The document
is the full JSON document of the resource being acted on.
topic: "/topics/messages"
action: "create|update|delete"
document: {Message}
topic: "/topics/events"
action: "create|update|delete|notify"
document: {Event}