pushe-webpush

1.3.1 • Public • Published

Pushe Webpush SDK

Pushe.co's SDK for webpush

Documentation

Installation

Using npm:

npm i -P pushe-webpush

Import

var Pushe = require("pushe-webpush");

or if you use ES6:

import Pushe from "pushe-webpush";

Note: If you want to use it with a script tag in your html you can do so like this:

<html>
  <head>
    <script src="https://static.pushe.co/pusheweb.js"></script>
  </head>
  <body>
  </body>
</html>

Initialize Push Service

To initialize Pushe webpush service in your app/website use Pushe.init() with your appId that is provided to you when you created your app in Pushe console.

var appId = "Your app id";

Pushe.init(appId);

Subscribe User

To subscribe users in your app or website use Pushe.subscribe().

Pushe.subscribe();

Note: This will ask user for permission if it is the first time subscribing. You can use it in your app whenever you want the subscription to happen.

Unsubscribe User

Use Pushe.unsubscribe() to unsubscribe the user from push events.

Pushe.unsubscribe();

ServiceWorker

To use webpush functionality you also need to put our ServiceWorker in root directory of your app/site.

  1. Create a file named pushe-sw.js and put it in root of your app/site
  2. Put the below line in pushe-sw.js:
    importScripts("https://static.pushe.co/pusheweb-sw.js");

Readme

Keywords

none

Package Sidebar

Install

npm i pushe-webpush

Weekly Downloads

7

Version

1.3.1

License

MIT

Unpacked Size

468 kB

Total Files

17

Last publish

Collaborators

  • npm
  • alireza_sadeghi
  • amir_aleahmad
  • pushe