Skip to content

Waasi/pusho-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pusho JS

Pusho Service client for JavaScript

Installation

npm install pusho-js

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

About

Pusho Service client for JavaScript

Resources

License

Stars

Watchers

Forks

Packages

No packages published