Skip to main content

Integrate Notifications via Delivery Node

tip

Do check out integrating notifications section for your frontend to see other recommended ways for integrating notifications on your frontend.

Overview

Push delivery Nodes is a Whitelabel solution to enable any app, either mobile, desktop, or extension, to allow Web3 push notifications to their app.

It is a decentralized solutions to enable web3 to web2 bridging. It allows any platform (whether centralized or decentralized) to receive communication from Push storage nodes, i.e., the nodes validating and indexing all communications and tying them to your wallet address (and multi-chain identity).


Setup

The whitelabel solution of Push delivery node is located in this github repo. Below are the steps for getting started —

Step 1️⃣ - Prerequisites

  • MYSQL (Version >= 5.7)
  • Redis (Version >= 6.0)
  • Docker (For local setup)
  • Google FCM Account Setup

Step 2️⃣ - Clone Push delivery node repo

git clone https://github.com/push-protocol/push-delivery-node.git

Step 3️⃣ - Environment configuration

Refer env sample file. The MYSQL DB credentials and Redis URL needs to be updated. The remaining conf need not be edited as of now.

If you use docker-compose for the local setup MYSQL DB and Redis config can be left as it is.

# REDIS

REDIS_URL=redis://localhost:6379

# DELIVERY NODE MYSQL DATABASE

DELIVERY_NODE_DB_HOST=localhost
DELIVERY_NODE_DB_NAME=dbname
DELIVERY_NODE_DB_USER=user
DELIVERY_NODE_DB_PASS=pass
DELIVERY_NODE_DB_PORT=3306

Step 4️⃣ - Infra Setup: Local

The docker-compose will bring up the MYSQL, Redis, and PHPMyAdmin containers for the delivery node.

docker compose up

Step 5️⃣ - (Optional) Infra Setup: Server (Production)

  • Host MYSQL and Redis Separately
  • Add MYSQL and Redis credentials in the .env file

Step 6️⃣ - FCM Project Setup

  • Refer Firebase docs to setup FCM
  • Create the firebase-adminsdk.json file in the root folder and add the FCM JSON to this file

Step 7️⃣ - Build the delivery node project

You should then be able to build the project using

cd push-delivery-node
npm install

Step 8️⃣ - Start the delivery node project

You should then be able to start the server using the following

cd push-delivery-node
npm start

Step 9️⃣ - Device Registration

  • An endpoint is hosted as part of the delivery node project, which can be used for Device Registration.
  • Below is the API to create a mapping between the wallet address and the device token for which the messages need to be delivered.
  • <delivery_node_url> is the base URL of the delivery node you have hosted.

Below is the curl request of this endpoint


curl --location --request POST 'https://<delivery_node_url>/apis/v1/pushtokens/register' \
--header 'Content-Type: application/json' \
--data-raw '{

"wallet": "eip155:0x35B84d6848D16415177c64D64504663b998A6ab4",
"device_token": "device_token",
"platform": "android"
}'