pusho

0.0.1 • Public • Published

Pusho JS

Pusho Service client for JavaScript

**Note: Still under development

Usage

const pusho = require('pusho');

/**
 * Create a Connection
 */

const host = 'http://localhost:4000';
const apiKey = 'my-api-key'; // Generated by Pusho

const conn = pusho.connect(host, apiKey);

/**
 * Subscribe to Get Push Notifications
 */

const fingerprint = 'my-unique-fingerprint';

const notificationHandler = ({ msg } => {
  // handle the message here
  alert(msg);
});

const subscription = pusho.notifications.subscribe(conn, fingerprint, notificationHandler);

/**
 * Unsubscribe from push notifications
 */

pusho.notifications.unsubscribe(subscription);

/**
 * Send push notifications to client.
 * Note: mostly used on backend systems
 */

const myPayload = 'Hello World!'; // Can be anything
pusho.notifications.push(fingerprint, myPayload);

Contributing

  1. Fork it ( https://github.com/[my-github-username]/pusho-js/fork )
  2. Create your feature branch (git checkout -b feature/my_new_feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Package Sidebar

Install

npm i pusho

Weekly Downloads

0

Version

0.0.1

License

MIT

Unpacked Size

4.9 kB

Total Files

7

Last publish

Collaborators

  • waasi