Pusher Beams is a cross-platform push notification API service provided by Pusher.

To enable Pusher Beams integration, you need to create a Pusher Beams Instance and use both Instance ID and Secret Key from the Instance dashboard.

Setting the Device Token

Once Pusher Beams instance has been created, and the Pusher Beams SDK has been set up and configured for your application, you can associate users with their devices using Authenticated Users.

This identifier allows targeting your user when sending push notifications without having to retrieve the specific Web, Android or iOS device tokens - which are managed by Pusher Beams.

In order to target the Pusher Beams user from Novu, you must register the Pusher Beams Authenticated Users with their userId as the deviceToken for your Novu subscriber. This value can be retrieved via getUserId() method from the SDK for your platform.

Once you have the user’s userId value, the deviceToken for your Novu subscriber can be set via:

import {
  Novu,
  ChatProviderIdEnum
} from '@novu/node';

const novu = new Novu("<NOVU_SECRET_KEY>");

await novu.subscribers.setCredentials('subscriberId', PushProviderIdEnum.PusherBeams, {
// Your user's unique 'userId' from Pusher Beams
deviceTokens: ['userId-from-pusher-beams'],
});

Checkout the API reference for more details.

SDK Trigger Example

import { Novu } from "@novu/node";

const novu = new Novu("<NOVU_SECRET_KEY>");

novu.trigger("<WORKFLOW_TRIGGER_IDENTIFIER>", {
  to: {
    subscriberId: "<SUBSCRIBER_ID>",
  },
  payload: {
    custom_data: "custom_data", // the payload will be sent as notification data object. Cannot contain the key “pusher”
  },
});