0.0.1 • Published 6 years ago

pusho v0.0.1

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

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