Many services for delivering push messages to mobile devices are not designed for decentralized networks. They require the mobile application to be bound to an account on the service and a single server to send messages to this account. To work around this limitation, the Moera network uses dedicated Push Relay servers that accept push messages from nodes and route them to their clients. Each node should provide a token it got from the client that confirms that the node has the right to send notifications to the client. Nodes authenticate on the relay using short-living tokens signed with the node's signing key.
Moera Push Relay API is based on JSON-RPC protocol. Until the API is stabilized, it may be changed in various ways and backward compatibility is not guaranteed.
timestamp
below is the number of seconds that passed since 01-01-1970 00:00:00 in UTC timezone.
Register a client to receive messages from the specified node. The client will be unregistered automatically if the relay gets an error from the push service indicating that the client cannot receive messages anymore.
String
clientId
– ID/token of the target client to receive messages
String
nodeName
– name of the node that will send messages
String
lang
– language of the messages (use standard language codes, like "en_US" or "uk")
timestamp
signedAt
– timestamp of the signature, the signature will be valid 2 minutes after the time specified
byte[]
signature
– the signature
(use PushRelayRegister fingerprint)
Send a message to node's clients about number of new stories in a feed.
String
feedName
– name of the feed
int
notViewed
– number of stories that have not been viewed yet
int
notViewedMoment
– moment of the oldest non-viewed story
String
nodeName
– name of the node that is sending the message
timestamp
signedAt
– timestamp of the signature, the signature will be valid 2 minutes after the time specified
byte[]
signature
– the signature
(use PushRelayMessage fingerprint)
Send a message to node's clients about a new story.
StoryInfo
story
– the story
String
nodeName
– name of the node that is sending the message
timestamp
signedAt
– timestamp of the signature, the signature will be valid 2 minutes after the time specified
byte[]
signature
– the signature
(use PushRelayMessage fingerprint)
Send a message to node's clients about deleting a story.
String
storyId
– ID of the story
String
nodeName
– name of the node that is sending the message
timestamp
signedAt
– timestamp of the signature, the signature will be valid 2 minutes after the time specified
byte[]
signature
– the signature
(use PushRelayMessage fingerprint)
Type | Field | Comment |
---|---|---|
String
|
objectType |
PUSH_RELAY_REGISTER |
String
|
clientId |
|
String
|
lang |
|
timestamp
|
signedAt |
of the current revision |
Type | Field | Comment |
---|---|---|
String
|
objectType |
PUSH_RELAY_MESSAGE |
timestamp
|
signedAt |
of the current revision |
Code | Name | Description |
---|---|---|
1 |
client-id.empty |
clientId is empty |
2 |
client-id.too-long |
clientId is too long |
3 |
node-name.empty |
nodeName is empty |
4 |
node-name.unknown |
nodeName is unknown |
5 |
lang.too-long |
lang is too long |
6 |
node.no-clients |
the node has node clients (the node should stop sending messages for them) |
7 |
story.empty |
story is empty |
8 |
story.invalid |
story format is invalid |
9 |
story.type-unknown |
story.storyType is unknown |
10 |
story-id.empty |
storyId is empty |
11 |
signed-at.empty |
signedAt is empty |
12 |
signed-at.too-old |
signedAt is too old |
13 |
signature.empty |
signature is empty |
14 |
signature.incorrect |
signature is incorrect |