Namespace, Primitive, Method
    Wondering what’s next for npm?Check out our public roadmap! »

    @pusher/push-notifications-server
    TypeScript icon, indicating that this package has built-in type declarations

    1.2.1 • Public • Published

    Build Status

    Pusher Beams Node.js Server SDK

    Full documentation for this SDK can be found here

    Installation

    The Beams Node.js server SDK is available on npm here.

    You can install this SDK by using npm:

    $ npm install @pusher/push-notifications-server --save

    Or yarn if you prefer:

    $ yarn add @pusher/push-notifications-server

    Usage

    Configuring the SDK for Your Instance

    Use your instance id and secret (you can get these from the dashboard) to create a Beams PushNotifications instance:

    const PushNotifications = require('@pusher/push-notifications-server');
     
    let pushNotifications = new PushNotifications({
      instanceId: 'YOUR_INSTANCE_ID_HERE',
      secretKey: 'YOUR_SECRET_KEY_HERE'
    });

    Publishing a Notification

    Once you have created your Beams PushNotifications instance, you can immediately publish a push notification to your devices, using Device Interests:

    pushNotifications.publishToInterests(['hello'], {
      apns: {
        aps: {
          alert: 'Hello!'
        }
      },
      fcm: {
        notification: {
          title: 'Hello',
          body: 'Hello, world!'
        }
      }
    }).then((publishResponse) => {
      console.log('Just published:', publishResponse.publishId);
    }).catch((error) => {
      console.log('Error:', error);
    });

    Install

    npm i @pusher/push-notifications-server

    DownloadsWeekly Downloads

    6,333

    Version

    1.2.1

    License

    MIT

    Unpacked Size

    52.5 kB

    Total Files

    18

    Last publish

    Collaborators

    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar