Everything You Need To Get Started With Push Protocol πŸ””!

Everything You Need To Get Started With Push Protocol πŸ””!

Sep 9, 2023Β·

4 min read

Introduction

Push Protocol is a Web3 communication network enabling cross-chain notifications and messaging for dapps, wallets, and services. Push powers communication for over 100 of the world’s leading dapps and service providers across DeFi, NFTs, gaming, dev tools, and more. Push is currently live on Ethereum, Polygon and BNB Chain.

Until Push, no solution existed to enable native communication between wallets in response to on- and off-chain data. The result was a fractured dapp ecosystem, held together by antiquated and centralized communication platforms.

Push is building the communication network for Web3, addressing a gap in critical infrastructure and improving the everyday experience for blockchain users. Its statistics comprise 47M Notifications, 120k+ Total Subscribers, 450+ Total Push integrations, and much more.

Some Stunning Features

  • Push Notifications- directly connect applications to individual users, enabling secure and personalized communication in response to customized on- and off-chain activity.

Click here to get started with Push Notifications.

  • Push Chat- is the leading decentralized, web3 native chat application with user-friendly features like 1-1, group chat, videos/images, and (soon) streaming.

Click here to get started with Push Chat.

  • Push Tokens- The $PUSH token enables governance, modification of protocol fees and features, network security, and fee management among all wallets that integrate Push, including Push governance participants.

In this article, we'll explore Push Notifications!

Why Do You Need Push?

Earlier, the Web2 ecosystems had traditional ways of communicating with each other resulting in broken solutions. Even in the world of Blockchain technology, before Push, no application, service provider, or wallet could communicate with each other. So, in order to ease out the workflow for Organizations and DAOs, Push came up with their product!

How To Start Using Push Notifications πŸ””?

To get started visit the Push Protocol Documentation here.

  • Any user who activates themselves on the protocol to send a notification is called a Channel. Channel stakes fees in a stake pool and the token incentives accumulated would be distributed among their subscribers in a weighted proportion.

  • In other words, a Channel is any service (protocol, dApp, or even web2 service) that wants to send notifications out to web3 usernames (wallet addresses).

  • A wallet address can create only one Channel on the Push Protocol.

  • To know more about creating a Channel visit here. If you wanna learn about creating a Channel on the Polygon chain then click here, and if you wanna know about creating one on BNB chain then click here.

  • Push provides flexibility in sending different types of notifications. To understand more about it click here.

  • You can easily send notifications by using the SDKs provided by Push, to use them visit here.

Installation-

npm install @pushprotocol/restapi@latest ethers

Here's an example of how to use Push SDKs-

import * as PushAPI from "@pushprotocol/restapi"; // Using the import statement
import * as ethers from "ethers";

const PK = 'your_channel_address_secret_key'; // Channel private key
const Pkey = `0x${PK}`;
const _signer = new ethers.Wallet(Pkey);

const sendNotification = async() => {
  try {
    const apiResponse = await PushAPI.payloads.sendNotification({
      signer: _signer,
      type: 1, // Broadcast
      identityType: 2, // Direct payload
      notification: {
        title: `[SDK-TEST] notification TITLE:`,
        body: `[sdk-test] notification BODY`
      },
      payload: {
        title: `[sdk-test] payload title`,
        body: `sample msg body`,
        cta: '',
        img: ''
      },
      channel: 'eip155:5:0xD8634C39BBFd4033c0d3289C4515275102423681', // Channel address
      env: 'staging'
    });
  } catch (err) {
    console.error('Error: ', err);
  }
}

sendNotification();

How To Integrate Push Protocol Into Your Project?

To receive notifications, the user must opt-in to the channel. This is done only once and is gasless, the user only needs to sign a message.

To see all the supported channels on Push, go to Push Protocol dapp and opt-in to your favorite protocol to receive notifications.

  • Get User Notifications- This is useful for getting all the notifications from a user.
const notifications = await PushAPI.user.getFeeds({
  user: 'eip155:5:0xD8634C39BBFd4033c0d3289C4515275102423681', // user address in CAIP
  env: 'staging'
});
  • Get User Subscriptions- This is useful for getting the list of channel addresses subscribed by a user.
const subscriptions = await PushAPI.user.getSubscriptions({
  user: 'eip155:5:0xD8634C39BBFd4033c0d3289C4515275102423681', // user address in CAIP
  env: 'staging'
});

Push Protocol provides many such amazing features. To enjoy the benefits visit the docs here.

Can It Be Used In Real Life?

The answer is yes!!

If you think that Push Protocol has no real-life implementation then you're wrong. You can build FullStack Decentralized Platforms and solve problems for many DAOs by helping them manage their users, communication layers, etc. In short, Push provides a one-stop solution to all your problems.

Some Problems You Might Encounter

Push Protocol is open source, so if you ever face any bugs and can't solve them then make sure to raise an issue by visiting here. As well as, if you face any issues while working on Push SDKs then visit the docs by clicking here.

Enjoyed this article? Then make sure to visit Push Protocol.

I hope that you must have found this article quite helpful. If yes, then do give a read to some of my other articles!

Who knows you might become a great programmer πŸ€”!

Β