docker-compose up --build --scale push_server=3This command will use
docker-compose.yamlANDdocker-compose.override.yaml
Replace
3by the the number ofpush_serverinstances you want
cp archethic-messaging-notification.service /etc/systemd/system
systemctl daemon-reloadsystemctl start archethic-messaging-notification
systemctl stop archethic-messaging-notification
journalctl -u archethic-messaging-notification -fDetails
sequenceDiagram
autonumber
participant Mobile as 📱 ArchethicWallet
participant Node as Nodes
participant Redis as Redis
participant Firebase as Firebase Cloud Messaging
Mobile->>Node: Notification send request
Node->>Node: Request validation
Node->>Redis: Websocket notification
Node-->>Redis: Read push tokens
Node->>Firebase: Push notif
Details
sequenceDiagram
autonumber
participant Mobile as 📱 ArchethicWallet
participant Node as Nodes
participant Redis as Redis
participant Firebase as Firebase Cloud Messaging
Mobile->>Firebase: Get Push notif token
Mobile->>Node: Save prefered language
Node->>Redis: Save settings for Push token
Mobile->>Node: Subscribe Push notifications for a TxChain
Node->>Redis: Add push token to TxChain listeners
Note over Mobile,Firebase: A TxSent event is received
Firebase->>Mobile: Push notification
Details
sequenceDiagram
autonumber
participant Mobile as 📱 ArchethicWallet
participant Node as Nodes
participant Redis as Redis
participant Firebase as Firebase Cloud Messaging
Mobile->>Node: Subscribe to TxSent events on a TxChain
Node->>Redis: Add mobile to TxChain room
Note over Mobile,Firebase: A TxSent event is received
Redis-->>Node: TxSent event
Node->>Mobile: TxSent event
When your application has created a new transaction, it can send a notification to all listeners (websocket and PUSH).
The notification must be sent 20 seconds maximum after the transaction creation.
Request
POST /transactionSent
{
// Genesis addresses of the updated transaction chains
txChainGenesisAddress: string
// Addresses of the new transaction
txAddress: string
// PUSH notification payload. Indexed by language.
pushNotification: Map<string, PushNotification>
// Signature of the concatenation of `txAddress` and
// `txChainGenesisAddress`.
// Signature is made with the private key used
// to sign the previous transaction.
payloadSignature: string
}PushNotification = {
title: string
body: string
}{
"txChainGenesisAddress": "0000f5024b5290588d56e9b5600d517a7f9595af3a65f2e742e3757196f57fb4ad17",
"txAddress": "0000b0e59c13138a7a3ad64e73857b600043bd71a5dc90420c14e28c57722185c282",
"payloadSignature": "...",
"pushNotification": {
"en": {
"title": "New message",
"body": "Bob sent you a message."
},
"fr": {
"title": "Nouveau message",
"body": "Bob vous a envoyé un message."
}
}
}
Error Responses
{
"error": "A reason"
}Call this to receive PUSH notifications when a new transaction arrives on any of the specified transaction chains.
You should call this method when your push token changes too.
Request
POST /subscribePush
Body:
{
// Your application's installation FCM token
pushToken: string,
// Genesis addresses of the transaction chains to listen
txChainGenesisAddresses: Array<string>
}Error Responses
{
"error": "A reason"
}Call this to stop receiving PUSH notifications when new transaction arrives on any of the specified transaction chains.
Request
POST /unsubscribePush
Body
{
// Your application's installation FCM token
pushToken: string,
// Genesis addresses of the transaction chains to listen
txChainGenesisAddresses: Array<string>
}Error Responses
{
"error": "A reason"
}Call this to setup the PUSH notifications you wish to receive. For now, you can only change the expected language.
Request
PUT /pushSettings
Body
{
// Your FCM token
pushToken: string,
// The expected locale
locale: string,
}Error Responses
{
"error": "A reason"
}A socket.io server is used for Websocket notifications.
/socket.io
To receive notifications, you need to listen to TxSent events.
You must subscribe to specific transaction chains updates too.
Notifications body :
{
// Genesis addresses of the updated transaction chains
txChainGenesisAddress: string
// Addresses of the new transaction
txAddress: string
// PUSH notification payload. Indexed by language.
pushNotification: Map<string, PushNotification>
// Signature of the concatenation of `txAddress` and
// `txChainGenesisAddress`.
// Signature is made with the private key used
// to sign the previous transaction.
payloadSignature: string
}PushNotification = {
title: string
body: string
}Call this to receive TxSent events when a new transaction arrives on any of the given transaction chains.
Message
Name
subscribe
Body:
{
// Genesis addresses of the transaction chains to listen
txChainGenesisAddresses: Array<string>
}Call this to stop receiving TxSent events when a new transaction arrives on any of the given transaction chains.
Message
Name
unsubscribe
Body:
{
// Genesis addresses of the transaction chains to listen
txChainGenesisAddresses: Array<string>
}