Skip to main content

Get started

Push Notification enables web3 native notification alerts between wallets. To do so, you will be using Push SDK API that will abstract away the complexity of authentication, encryption, signing, sending and receiving of notifications.

Speed run​

The following speed run is designed to give you a quick overview of usage and demonstrates how Push Notification can be integrated successfully in minimal lines of code.

// Import Push SDK & Ethers
import { PushAPI, CONSTANTS } from '@pushprotocol/restapi';
import { ethers } from 'ethers';

// Creating a random signer from a wallet, ideally this is the wallet you will connect
const signer = ethers.Wallet.createRandom();

// Initialize wallet user
// 'CONSTANTS.ENV.PROD' -> mainnet apps | 'CONSTANTS.ENV.STAGING' -> testnet apps
const userAlice = await PushAPI.initialize(signer, {
env: CONSTANTS.ENV.STAGING,
});

// List inbox notifications
const inboxNotifications = await userAlice.notification.list('INBOX');

// List spam notifications
const spamNotifications = await userAlice.notification.list('SPAM');

// Push channel address
const pushChannelAdress = '0xB88460Bb2696CAb9D66013A05dFF29a28330689D';

// Subscribe to push channel
await userAlice.notification.subscribe(
`eip155:11155111:${pushChannelAdress}` // channel address in CAIP format
);

// Send notification, provided userAlice has a channel
const response = await userAlice.channel.send(['*'], {
notification: {
title: 'You awesome notification',
body: 'from your amazing protocol',
},
});

// To listen to real time notifications
const stream = await userAlice.initStream([CONSTANTS.STREAM.NOTIF]);

// Set stream event handling
stream.on(CONSTANTS.STREAM.NOTIF, (data) => {
console.log(data);
});

// Connect to stream
stream.connect();

Installation​

# Install Libraries
npm install @pushprotocol/restapi@latest ethers@^5.7

Quickstart from SDK repos​

Workshop Video​


Testing​

Receiving notifications​

Best way to experience notification is with a frontend that already supports Push Protocol, here are few of our favorite crypto wallets —

Prod Environment

Staging Environment

note

iOS doesn't have a public staging app (only production app is available on the App Store).

Best way to test staging on iOS would be to join 👉 Push Discord Channel 👈 and ask a team member to provide you with a testflight beta link.

Push SDK playground and full API coverage​

Full API coverage with sample runable code can be found in the examples below: