-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #293 from im-perativa/staging
docs(pusher-beams): add pusher beams doc
- Loading branch information
Showing
2 changed files
with
50 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
--- | ||
title: 'Pusher Beams' | ||
description: 'Learn how to use the Pusher Beams provider to send push notifications using Novu' | ||
--- | ||
|
||
[Pusher Beams](https://pusher.com/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](https://dashboard.pusher.com/beams/). | ||
|
||
# Setting the Device Token | ||
|
||
Once Pusher Beams instance has been created, and the Pusher Beams SDK has been [set up and configured](https://pusher.com/docs/beams/reference/all-libraries/) for your application, you can associate users with their devices using [Authenticated Users](https://pusher.com/docs/beams/guides/publish-to-specific-user/web/). | ||
|
||
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()](https://pusher.com/docs/beams/reference/web/#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: | ||
|
||
```jsx | ||
import { Novu, PushProviderIdEnum } from '@novu/node'; | ||
|
||
const novu = new Novu("<NOVU_API_KEY>"); | ||
|
||
await novu.subscribers.setCredentials('subscriberId', PushProviderIdEnum.PusherBeams, { | ||
// Your user's unique 'userId' from Pusher Beams | ||
deviceTokens: ['xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'], | ||
}); | ||
|
||
``` | ||
|
||
# SDK Trigger Example | ||
|
||
```jsx | ||
import { Novu } from '@novu/node'; | ||
|
||
const novu = new Novu("<NOVU_API_KEY>"); | ||
|
||
novu.trigger('event-name', { | ||
to: { | ||
subscriberId: '...', | ||
}, | ||
payload: { | ||
custom_data: 'custom_data', // the payload will be sent as notification data object. Cannot contain the key “pusher” | ||
}, | ||
}); | ||
|
||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters