Pushwoosh Web Push Notification SDK
![platforms](https://img.shields.io/badge/platforms-Chrome%20%7C%20Firefox%20%7C%20Safari-green.svg)
Integration
-
Download Pushwoosh Web Push SDK and unzip it. You should have the following files: manifest.json
, pushwoosh-service-worker.js
-
Place all these files to top-level root of your website directory.
-
Open manifest.json and make the following changes:
- Change name and short_name to the name of your website.
- Change
gcm_sender_id
to your Sender ID. Please keep in mind that Sender ID is usually a 12-digit number, and it can't contain any letters.
-
Include manifest.json in <head>
<link rel="manifest" href="/manifest.json">
Installation
via npm
npm install web-push-notifications --save
via html
<script type="text/javascript" src="//cdn.pushwoosh.com/webpush/v3/pushwoosh-web-notifications.js" async></script>
Usage
import {Pushwoosh} from 'web-push-notifications';
const pwInstance = new Pushwoosh();
pwInstance.push(['init', {
logLevel: 'info',
applicationCode: 'XXXXX-XXXXX',
safariWebsitePushID: 'web.com.example.domain',
defaultNotificationTitle: 'Pushwoosh',
defaultNotificationImage: 'https://yoursite.com/img/logo-medium.png',
autoSubscribe: false,
subscribeWidget: {
enable: true
},
userId: 'user_id',
tags: {
'Name': 'John Smith'
}
}]);
pwInstance.push(function(api) {
console.log('Pushwoosh ready');
});