Receiving via Delivery Node
Receiving notifications via Neo Cast Delivery Nodes is a versatile solution for enabling Web3 Neo Cast notifications in various apps, including mobile, desktop, or extensions. These nodes facilitate web3 to web2 bridging, allowing any platform, whether centralized or decentralized, to receive communications from Neo Cast storage nodes, which validate and index all communications tied to users' wallet addresses and multi-chain identities. Below are the steps to get started with the Delivery Node Module:
Prerequisites:
MYSQL (Version >= 5.7)
Redis (Version >= 6.0)
Docker (For local setup)
Google FCM (Firebase Cloud Messaging) Account Setup
Step 1: Clone Neo Cast Delivery Node Repo
git clone https://github.com/ethereum-push-notification-service/push-delivery-node.git
Step 2: Environment Configuration
Refer to the env sample file. Update the MYSQL DB credentials and Redis URL. The remaining configuration can be left as is. If you use docker-compose for the local setup, you can leave the MYSQL DB and Redis config as they are.
Example .env
configuration:
# 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 3.a: Infrastructure Setup (Local)
Docker-compose will bring up the MYSQL, Redis, and PHPMyAdmin containers for the Delivery Node.
docker-compose up
Step 3.b: Alternate Infrastructure Setup (Production)
Host MYSQL and Redis separately and add their credentials in the .env
file.
Step 4: FCM Project Setup
Refer to the Firebase Cloud Messaging documentation to create an FCM project. Create a firebase-adminsdk.json
file in the root folder and add the FCM JSON to this file.
Step 5: Build the Delivery Node Project
Navigate to the push-delivery-node
directory and install dependencies.
cd push-delivery-node
npm install
Step 6: Start the Delivery Node Project
You can start the server using the following command:
cd push-delivery-node
npm start
Step 7: Device Registration
An endpoint is hosted as part of the Delivery Node Project, which can be used for Device Registration. This endpoint allows you to create a mapping between a wallet address and a device token to which messages need to be delivered.
Replace <delivery_node_url>
with the base URL of the Delivery Node you have hosted. Here's a curl request example to register a device:
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"
}'
This API call registers a device associated with a specific wallet address, allowing messages to be delivered to the registered device.
Last updated